News for hackers. Stuff that matters.
Re:How to Handle Monetary Values in JavaScript by aaaaaaaaaab on Tuesday October 30, 2018 @04:20PM (#18340928)
Integers can be represented exactly in IEEE754.
Re:How to Handle Monetary Values in JavaScript by noselasd on Tuesday October 30, 2018 @05:20PM (#18341375)
Not all of them, e.g. 9007199254740993 can't be represented in a double precision format (what javascript uses)

For single precision floats you start having issues representing integers as low as 16777217

Re:How to Handle Monetary Values in JavaScript by aaaaaaaaaab on Tuesday October 30, 2018 @06:05PM (#18341683)
Sure, you can’t represent Graham’s number either...

I know you knew what I meant.

Re:How to Handle Monetary Values in JavaScript by noselasd on Tuesday October 30, 2018 @07:56PM (#18342267)
No not really. You have to define the bounds you were talking about.

People believing that a float type can represent all integers that the int type in their language can represent is not exactly uncommon.

Re:How to Handle Monetary Values in JavaScript by maxxxxx on Tuesday October 30, 2018 @05:05PM (#18341269)
How about 2.1?

According to this https://www.h-schmidt.net/FloatConverter/IEEE754.html

2.1 will be represented as 2.099999904632568359375

Re:How to Handle Monetary Values in JavaScript by noselasd on Tuesday October 30, 2018 @05:21PM (#18341383)
well, 2.1 isn't an integer.