Floating Point Numbers
- Posted by Mathew Hounsell <mfh03 at UOW.EDU.AU> Mar 21, 2000
- 420 views
It is a simple, if sad, truth that floating point numbers are unreliable. If you want accurate representation of decimal and fractional numbers you must use a specialist library. These specialist libraries internally use integers. Only integers are accurate in computing. The IEEE has long recognized that floating point numbers are in-accurate. Their standard takes this into account. There is no point considering the source code for euphoria. It is a compiled language and the order of operations is set by the compiler. There is in fact no guarantee in order of operations in C. This is often stated by C gurus when some one questions the results of floating point operations. The only solution is to use integers only. For an assignment we had to take an order an calculate the cost. The floating point calculations were wrong. The costs were in dollars and cents. As it is a fixed position decimal I represented the prices in cents. When I dealt with it, I dealt with it in cents. I out-putted it as dollars and cents. This meant it was accurate and the user was not confused by incorrect results or prices in cents. ------------------------- Sincerely, Mathew Hounsell mat.hounsell at excite.com