LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

setting double precision accuracy within CVI

I am using LabWindows/CVI version 8.0.1 to port some mathmatic modeling done using Matlab.  Matlab uses 14 decimal places to represent its floating point values, while  CVI uses 15 places.  Due to the recursive nature of the model I am porting, there is an accumlation of error such that the decisions made are not consistant between the CVI and MatLab verison of the model.  For the purpose of testing the CVI version of the model, it is important to ensure that given identical input, the models produce identical output. 

Question:  Is there a way (a variable in a header file for instance) to set LabWindows to only use 15 decimal places to represent floating points rather than the default 16 places, thereby eliminating this source of error.
0 Kudos
Message 1 of 3
(3,484 Views)
    Correction:  In the original post, I meant to request if there was a way to set CVI to use only 14 places in representing floating point rather than the default 15 places.

0 Kudos
Message 2 of 3
(3,482 Views)
Hi Ryykker,
 
I would recommend rounding at key portions of your code in order to use only 14 decimal places.  You can use the divide by 10 trick, in combination with rounding. 
 
CVI conforms to the ANSI C and IEEE standard formats for data types and byte sizes.  It may be possible to edit float.h, an ANSI C header file we use to determine precision width of floats and doubles. You can find it in the C:\Program Files\National Instruments\CVI81\include\ansi directory. There may be other repercussions of this, however.  I would definitely make a backup copy. 
Cheers,

David Goldberg
National Instruments
Software R&D
0 Kudos
Message 3 of 3
(3,443 Views)