Little issue with zeros in floats under HTML5

Monkey Targets Forums/HTML5/Little issue with zeros in floats under HTML5

PhillipK(Posted 2014) [#1]
Heyho,

i found a little bug thats appears in my html5 builds.
After a little lookaround, it only appears with floats and zeros before them, like:
05.0
The game simple dont load on opera / firefox.

Here is a little demonstration sample:

Strict

Import mojo

Class Game Extends App

	Field x:float
	Field y:Float
	
	Field dirX:Float
	Field dirY:Float
		

	Method OnCreate:Int()
		SetUpdateRate(30)
				
		Return 1
	End
	
	Method OnUpdate:Int()
	
		While (x + dirX) < 0 or (x + dirX) > DeviceWidth() or dirX = 0
			dirX = Rnd(-1, 1)
		Wend
		While (y + dirY) < 0 or (y + dirY) > DeviceHeight() or dirY = 0
			dirY = Rnd(-1, 1)
		Wend
	
		x += dirX
		y += dirY
		
		Return 1
	End
	
	Method OnRender:Int()
		Cls
		
		DrawRect(x - 5.0, y - 5.0, 10, 10)
		
		Return 1
	End

End

Function Main:Int()
	New Game()
	
	Return 1
End


Have a look on the line
DrawRect(x - 05.0, y - 05.0, 10, 10)

If you change the "05.0" to "5.0" it works like a charm.

I know, that there isn't a good reason to add 0's in front of the floats, but i just found that out.
Also, i can remember that i ran into this bug in the past, so i thought i should mention it,maybe it helps some others to run HTML5 without gettin angry :D

Ps: The values appear exactly like this in the *.js file:
bb_graphics_DrawRect(this.m_x-05.0,this.m_y-05.0,10.0,10.0);



nikoniko(Posted 2014) [#2]
PhillipK wrote:
DrawRect(x - 05.0, y - 05.0, 10, 10)


With this dev consoles reports about "ReferenceError: BBMonkeyGame is not defined:"

So problem is in javascript not in Monkey, isn't it?


PhillipK(Posted 2014) [#3]
I thought the same, nikoniko.
But its also an annoying behaviour and maybe it helps some other people if they know where to look when facing this problem.

* Edit:
Meant, i just wrote it down here to provide a lookup reference, not to complain.


nikoniko(Posted 2014) [#4]
In javascript digits are started with 0 (zero) mean octal based digits. http://en.wikipedia.org/wiki/Octal

Octal has no float digits so js generates exception when meets digit as 05.0


ziggy(Posted 2014) [#5]
Then this is a Monkey translator bug. Maybe we should tell Mark