LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to write last 48bits of a bouble variable

hi,

i would like to know how to write last 48bits of double type variable. i am trying create a certain memory format. it needs a 48bits of a one data point. since we C doen't have 48bit variable i created double variable. now i am trying to write last 48bits of this double.(most significant bits). any help would be appreciated.

Thanks,

0 Kudos
Message 1 of 4
(2,720 Views)

Double variables are treated by CVI according to IEEE 754 standard, which means the 64 bits are organized in groups to represent sign, exponent and mantissa of a floating point library. For this reason it seems to me that you may come into troubles by attempting to use some bits only of a double variable.

If you are not treating floating point numbers, you may consider to use '__int64' data type instead which is supported by CVI starting from release 7.0 on or the equivalent 'long long' data type introduced in CVI 8.5: both describe 8-bytes integers.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(2,718 Views)

Thanks for the reply Roberto. If  i use '_int64' data type how can i get last 48bits of that data type to write to the disk? Or  does labview support integer 48bit data type? the memory format i am trying to create requires this data to be 48bits.

Thanks

0 Kudos
Message 3 of 4
(2,706 Views)

I'm not aware of any 48-bit data types so you'll have to make do with something like three short types.  Something like this should work (from the interactive execution window):

 

static double d64 = 1234567890.0;
static short *s;

static short first16, second16, third16;

s = (short *)(&d64);

first16 = *(s + 0);
second16 = *(s + 1);
third16 = *(s + 2);

DebugPrintf("%d, %d, %d", first16, second16, third16);

 

 Where the short ints first16, second16, and third16 will give you the first, second, and third set of 16 bits from the double, respectively.  I have no idea how to do that in Labview.  Please note that this is the Labwindows forum.

0 Kudos
Message 4 of 4
(2,694 Views)