Infinity, negative infinity, and NaN

Monkey Forums/Monkey Bug Reports/Infinity, negative infinity, and NaN

Goodlookinguy(Posted 2013) [#1]
Can some changes be made to allow for infinity, negative infinity, and NaN without having to get hacky.

What I mean by this is, this works just fine in every output I did (HTML5, Flash, XNA, GLFW, BlitzMax, C++)
Function Main:Int()
	Local a := 0.0
	Local b := 1.0
	Local negInf := Log(a)
	Local posInf := b / a
	Local nan := a / a
	
	Print negInf
	Print posInf
	Print nan
End


This on the other hand gives a divide by zero error.
Function Main:Int()
	Local negInf := Log(0.0)
	Local posInf := 1.0 / 0.0
	Local nan := 0.0 / 0.0
	
	Print negInf
	Print posInf
	Print nan
End


I know Monkey attempts to do the math for static numbers ahead of time, so can something be changed to allow for this.

Edit: I was just thinking that Log(0.0) does work. So that part can be ignored. The other two on the other hand are a different case.

Edit 2: Optionally, can we just get these values as constants. That'd be even better.


John Galt(Posted 2013) [#2]
'Divide by zero' is pretty standard stuff and I would say it is more useful than a NaN. I agree these constants should be available, though.