Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

happen in Java floating point?

floating Java point
0
Posted

happen in Java floating point?

0

. There are several unexpected things that seem to bite programmers with floating point. Invariably this is a result of the programmer not being fully conversant with FP, rather than some fault in Java. If you seem to be having problems with floating point, your problem probably stems from the fact that floating-point arithmetic is inherently imprecise. You can expect up to 7 digits of precision with floats and 16 digits with doubles. However, that does not mean that a number that can be exactly represented in 7 digits decimal, can be exactly represented as a binary floating point number. On the contrary, that is usually not the case. Additionally, when Java converts floating point numbers to a String, as is done when they are output, enough digits are printed so the number can be read back in with no loss of precision. For this reason, you may see more “inaccuracies” in floating point output than you are used to. This policy actually gives you more consistent results than on a system

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123