Answer the question
In order to leave comments, you need to log in
Why is the accuracy of calculations in float violated for numbers of a certain power of two?
Hello! Can someone explain how floating point numbers work?
An example is the following:
Why do problems with precision occur for groups of numbers starting with a power of two in such a calculation? The first group starts at 16, the second at 64, and the third at 2048. I understand floats aren't guaranteed to be accurate, but why is it acting this way in this case? Just curious. _.range(0,2050).map(i => (i + 0.99) * 100);
Answer the question
In order to leave comments, you need to log in
Yes, floating point numbers are not guaranteed to be accurate. Read the Wikipedia article, it is quite adequate.
Don't count money in floating numbers :)
It is probably connected with the peculiarities of translating fractional numbers into text. I tried to repeat it in C++, nothing interesting happened. On the other hand, G++ and GRISU methods for converting fractional to text give slightly different results.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question