Ranter
Join devRant
Do all the things like
++ or  rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power realtime personalized recommendations and activity feeds using a simple API
Learn More
Comments

JavaScript only has one type for numbers, called Number. It's a floating point type, which doesn't even handle multiplication by powers of 10 particularly well (it should just add log10(n) to the exponent when multiplying by n=10^x)

What I'm saying is that a developer has a math problem. They think "I know, I'll use JavaScript's builtin number type". Now they have NaN problems.

joas19446yI'd imagine the number can be represented internally as many different binary forms. Integer, floating point and the whole gang.
So doing number crunching with JS using integers shouldn't usually differ much from for example C. (Implementation differentations may apply.)
And you can always use rounding or fractions to work around rounding errors. 
Ah yes, another JavaScript novice confused by its floating point mechanics.
"If you just don’t want to see all those extra decimal places: simply format your result rounded to a fixed number of decimal places when displaying it."
JavaScript uses the the IEEE 754 double precision floating point, the results you see on your screen are technically correct, but should be rounded to avoid "unusual" results.
Also JavaScript is not really the language you generally want to use for complex calculations; implement a Webservice on a Java or C# backend and use JavaScript for frontend. Another possibility would also be to take a powerful JS framework to support your backend later on, but be sure to learn the native JavaScript first!
Hope this helps and welcome to JS :) 
joas19446y@frickerg
To simplify the comment so that I would've got it some days backward.
1 = 0.999...
Is mathematically true, just two different representations of the same number. Integer and decimal.
1/2 = 0.5
Just like fractions can be represented as decimal number.
1/3 = 0.333...
Yes, even if they end up looking kind of wrong. But you have to believe. There's never a 4 at the end of the line. It's a recurring decimal number or whatever they call it. It's just a deal between mathematicians. And it works, don't touch it.
And let's not go to binary rounding errors, cus' even I can't wrap my head around it yet. 
py2js33816yDon't whine about it just use a workaround and move on, I am sure the creators/maintainers didn't leave it as is because of no reason. If so and so is a very big problem then choose another language.

@py2js I too whine about the fucking bullshit that is floating point math.
Had to write invoicing software in php, rounding errors galore.
This is one of those times we're allowed to whine.
Related Rants
Oh JavaScript... can you seriously not even increment the exponent of a float without barfing?
*siiiiiiiiiiiiiiiigh*
rant
js
i mean come on this is floating point 101