RosettaCodeData/Task/Extreme-floating-point-values/MiniScript/extreme-floating-point-valu...

23 lines
520 B
Plaintext

import "listUtil"
toBoolStr = function(n)
if n == 0 then return "false"
return "true"
end function
// create 'extreme' values from 'normal' values
negZero = -0
inf = 1 / 0
negInf = -1 / 0
nan = 0 / 0
// print them and do some arithmetic on them
print [inf, negInf, nan, negZero]
print [inf + inf, negInf + inf, inf * nan, nan * nan]
print [inf/inf, negInf/2, nan + inf, negZero/0]
// show some comparisons
comps = [negZero == 0, inf == -inf, inf == nan, nan == nan]
comps.apply @toBoolStr
print comps