26 lines
637 B
Plaintext
26 lines
637 B
Plaintext
number.isInfinite = function
|
|
return abs(self) == 1/0
|
|
end function
|
|
|
|
number.isNaN = function
|
|
return self != self
|
|
end function
|
|
|
|
number.toBoolStr = function
|
|
if self == 0 then return "false"
|
|
return "true"
|
|
end function
|
|
|
|
checkDivByZero = function(a, b)
|
|
c = a / b
|
|
if c.isInfinite or c.isNaN then return true
|
|
return false
|
|
end function
|
|
|
|
print "Division by zero?"
|
|
print " 0 / 0 -> " + checkDivByZero( 0, 0).toBoolStr
|
|
print " 1 / 0 -> " + checkDivByZero( 1, 0).toBoolStr
|
|
print " 1 / 1 -> " + checkDivByZero( 1, 1).toBoolStr
|
|
print " -5 / 0 -> " + checkDivByZero(-5, 0).toBoolStr
|
|
print " -5 / 2 -> " + checkDivByZero(-5, 2).toBoolStr
|