+ 2
Why is JS math wierd?
just look at this: https://code.sololearn.com/WQv56rsKmWT6/?ref=app
7 ответов
+ 10
@Johnathan. JS is fine at math. It is the floating point data type that is the problem here.
Excerpt from the article you linked:
It's interesting that this behavior is often attributed to JavaScript, while it’s pertaining to any language the uses floating point format for numbers. This means that if you use ‘float’ or ‘double’ data types in Java or C you’ll see the same result.
+ 5
idk this is really wierd , hope someone answer this question
+ 4
@jay, I do understand your point. But when it comes to precision calculations, JavaScript is not the best one. But there's hope based on @Ace's post.
+ 4
@Ojani: yes
+ 2
JavaScript is not really good at math.
0.1 + 0.2 !== 0.3.
It has only one number type which causes that error unlike other languages. That issue gave me a headache before.
https://medium.com/dailyjs/javascripts-number-type-8d59199db1b6
+ 2
I was thinking on making a calculator with JS and html. Should go for it anyways?