LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

64 bit floats in LabWindows CVI

Hi,
I have a very basic question about supported types in CVI.
I am writing a program that will count large number of clock cycles and then convert this count to a time
The count will be represented as an unsigned __int64 variable Ncount, but then I would like to get a number in seconds
 from such large count. If I define a variable ClockRes of type double which contains the duration of my clock cycle and I
 multiply that by the Ncount value, I get a warning  : Conversion from 'unsigned __int64' to 'double' might lose data.
When I do

double ClockRes;
double Time;
unsigned __int64 Ncount;

Time=Ncount*ClockRes;

is the LabWindows compiler type casting Ncount to a double and then multiplying?.

If that is the case, I understand why there will be a data loss. Is there any 64-bit representation floating number supported in CVI that I can use to  prevent data loss in this type of operation?.
I could not find documentation describing the supported 64-bit data types in CVI. Where can I find this information?
Thank you

Fundadero


0 Kudos
Message 1 of 5
(3,778 Views)

CVI uses the IEEE implementation of floating point numbers, so the double type has a precision of 53 bits. Providing your original number (Ncount) stored in a 64 bit quantity has fewer significant bits than this, you will not lose precision when the compiler converts it to a double. If you really need more precision, you may have to consider writing your own routines, unless you can find a third party library that does it for you.

JR

Message 2 of 5
(3,773 Views)
Thanks JR,
This resoves my issue, I have 48 significant bits only.
I should have gessed this, because sizeof(double) is 8 bytes. Just as the unsigned __int64 but where did you find the information for the datatypes for CVI.?
Thanks again!.

Fundadero

0 Kudos
Message 3 of 5
(3,741 Views)
I'm using CVI 7.0; if you fire up CVI help, select the Index tab and type in "data types", a page will appear detailing the supported types used by CVI. For floats and doubles, this refers to IEEE standard formats, for which there are many references to be found on the web. I usually use wikipedia and in this case it led to the definition showing the precision of 53 bits. (For the 8 byte version of floating point representation.)
 
JR
Message 4 of 5
(3,735 Views)
JR,
 I found the information in the CVI help. Very good.
Thanks man!
Fundadero

0 Kudos
Message 5 of 5
(3,729 Views)