01-09-2007 12:59 PM
01-09-2007 02:50 PM
There are two datatypes in CVI for floating point numbers: float (single precision accuracy) and double (double precision accuracy).
You'll get more accurate results if you use double instead of float.
The numeric controls which you place on your CVI UIR are double by default.
The answer is related to issues raised in your previous post. It is a limitation of how floating point numbers are represented and stored in binary. You can spend years searching article written on the subject, like the following google search:
http://www.google.com/search?hl=en&lr=&q=IEEE+floating+point+representation+inaccuracy
01-10-2007 07:43 AM
Thanks for the explaination, but it still bother me that even I defined f_val in double it is still not much better:
double f_val = 356.9; When I verified f_val, it shows 356.89999999... Meanwhile by CVI program (Set & Get), it can show 356.90.
However, I agree that when I defined double f_val = 356.99; then when I verified f_val it is equal 356.99. But can you explain the 356.9 case?
01-10-2007 02:54 PM - edited 01-10-2007 02:54 PM
This link explains the issue floating point representations of some decimal numbers http://docs.python.org/tut/node16.html
Message Edited by mvr on 01-10-2007 02:55 PM
01-10-2007 02:59 PM - edited 01-10-2007 02:59 PM
Message Edited by mvr on 01-10-2007 03:00 PM
01-10-2007 03:27 PM