Float precision
Hello, I am using float type variable to save number like 0.01, but when i print it to chat then number is shown as 0.099999. also it is not only print problem, if i make mathematical action between float variables (not very high precision, ex 5 digits after comma) precision of result is lost. why? how to fix it?
|
Re: Float precision
You can't, that's how IEEE754 single precision floating point numbers work, in every language. When formatting strings though you can use %.2f instead of just %f to display 2 digits after the decimal point, for example.
|
| All times are GMT -4. The time now is 12:41. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.