View Single Post
Quote:
 Originally Posted by Stijn it isn't
Oh, I do realize it isn't in math, but C++, which I believe AS is based on, does return infinity on division by 0. Floats can also keep positive and negative zero and the sign of infinity depends on the sign of zero (which is basically the only difference between +0 and -0). Usually, infinity is declared as `1.0/0.0`, minus infinity as `-1.0/0.0` and NaN as `0.0/0.0`. Division by ±infinity returns ±0 (and this part actually works correctly in AS). There are various forms of use for infinity and NaN. Or so I assume, because if there weren't, floats wouldn't be able to store them, right? Personally, I'm using them for min(), max(), mean() and median(), each of which is meant to have 2 or more arguments, and declaring them as `double min(double x1,double x2,double x3=INFINITY,double x4=INFINITY,...)` or `double mean(double x1,double x2,double x3=NaN,double x4=NaN,...)` was the best idea I was able to come up with.

Also, infinity, minus infinity and NaN work just fine in comparisons.
__________________

I am an official JJ2+ programmer and this has been an official JJ2+ statement.

Last edited by Sir Ementaler; Mar 8, 2013 at 07:21 AM.