This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Floating point arithmetic - accuracy problem

Hello,

I am using 89C51ED2 for solving non-linear equations. I am facing accuracy problems while doing floating point arithmetic. The accuracy of floating point arithmetic is limited to 3 decimal points thus leading to an erroneous results after a series of operations. Declaring variables as double doesn't solve the problem.How can I increase accuracy of floating point operations? Is there any way to solve this issue?

Thanks in advance.

Praveen K

Parents
  • You mean 3 decimal places? Not sure that's how floats even work, its the number of significant digits that is limited.

    You should probably check the maths, and the casting, and make sure you aren't throwing the precision out. Understand the scale of your numbers throughout the calculation. Rearrange the math if required.

    The least significant digits are the ones most at risk with floating point math. If you are dealing with very large numbers, try to remove those before doing the math that requires precision.

    Consider fixed point, BCD, bignum, etc. Review chapters on numeric representation

Reply
  • You mean 3 decimal places? Not sure that's how floats even work, its the number of significant digits that is limited.

    You should probably check the maths, and the casting, and make sure you aren't throwing the precision out. Understand the scale of your numbers throughout the calculation. Rearrange the math if required.

    The least significant digits are the ones most at risk with floating point math. If you are dealing with very large numbers, try to remove those before doing the math that requires precision.

    Consider fixed point, BCD, bignum, etc. Review chapters on numeric representation

Children