Forum Bugs

Math.floor() defect

StoneCypher
Math.floor() is returning float, but should return integer. This is very important for generated numeric tables.

http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf?page=12

John Haugeland is http://fullof.bs/

mikeday
Technically all numbers in JavaScript are double precision floating point numbers. You can always call Math.Floor(3.5).toFixed() to drop the decimal point.
StoneCypher
You can see the germane difference in .toString(), which by the standard should not return foo.0.

This breaks many, many javascript libraries.

John Haugeland is http://fullof.bs/

mikeday
Right, Number.toString() delegates to "9.8.1 ToString Applied to the Number Type", where step 6 appears to cover returning integral results with no decimal point. Implementing this could be a little fiddly, though. Might be easier if we just do the existing conversion and then chop ".0" off the string before returning it. :)
StoneCypher
The whole float and integer thing is cropping up pretty surprisingly often. It's not just floor; it's most math.

This becomes important if you use non-trivial operators. I have to convert to string, post-trim and parseInt to use operator modulus, operator shift, operator rotate, et cetera. Lots of really, really unexpected NaNs in weird places.

I would like to request stricter number type handling. This turns out to be a bigger problem than it seems like it would be at first.

John Haugeland is http://fullof.bs/

mikeday
We've fixed most of these issues in Prince 8.1, now available for download.