You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes, we want to check that a floating point number isn't NaN. We do this by comparing the number to itself: if value != value, then value is NaN.
A property can be defined make this a little prettier: isNumber ::= this == this
With it, the following program
value:=0.0f
value isNumber toString() println()
value /= value
value isNumber toString() println()
prints
true
false
But where should the function be added?
To Numbers.ooc (where it will always be available), or
to math.ooc (which will require anyone who wants to use it to import math)?
The text was updated successfully, but these errors were encountered:
Sometimes, we want to check that a floating point number isn't
NaN
. We do this by comparing the number to itself: ifvalue != value
, thenvalue
isNaN
.A property can be defined make this a little prettier:
isNumber ::= this == this
With it, the following program
prints
But where should the function be added?
Numbers.ooc
(where it will always be available), ormath.ooc
(which will require anyone who wants to use it toimport math
)?The text was updated successfully, but these errors were encountered: