LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert EXT to U64

Hi all,

 

I'm having trouble converting an EXT to a U64.

 

I searched the forum and found this excellent post for going the other way:  converting a U64 to an EXT.  This solved half my problem beautifully.

 

http://forums.ni.com/t5/LabVIEW/convert-64bit-UTC-time-since-1-jan-1601-to-current-time-labview/m-p/...

 

Unfortunately, I need to be able to go the other way also and I'm having trouble ascertaining how by looking at this code. I understand parts of it, but not the whole.  I haven't been successful in finding a conversion algorithm online (normally Mr. Google is more helpful than he was today).

 

Typecasting the EXT to a U64 doesn't give me accurate results (also discussed elsewhere on the forum, this is a lossy conversion).  Using the "to U64" function on the numeric conversion palette also does not give me accurate results.  I checked both of these things by inputting a U64 to the code shown in the link above, then taking the resulting EXT and attempting to convert it back to a U64 using either the numeric conversion function or a typecast.

 

This post discusses the issue with the numeric conversion function:

 

http://forums.ni.com/t5/LabVIEW/BUG-Large-floating-point-numbers-convert-to-the-wrong-integer/td-p/2...

 

It's wonderful that this was resolved in LV 2013, but I'm using LV 2012.

 

I think I need to figure out how to reverse the code I linked to above, but I don't understand it well enough to do so.  Can anyone help?

Thanks!

Diane

0 Kudos
Message 1 of 3
(2,122 Views)

Hi Diane,

 

I have looked through the Bug report, but there was no mention of the workaround or fix documentation that was implemented in the 2013 version, so we'll have to find a workaround.

 

Since this conversion issue only arises when the top 53 bits are set, I suggest starting up by checking your initial EXT. If those bits are set (you could do a conversion to string and compare the first 13 characters to FFFFFFFFFFFFF), then this is where the tricky bug comes in; if not it appears typecasting to U64 works out.

 

In the problematic case, a possible idea (that looks similar yet a little simpler to the VI you mentioned) would be to convert the EXT to a string, split the string in two, convert those separatly, concatenate the strings and convert back to a U64.

Xavier
Message 2 of 3
(2,066 Views)

That's a thought.  Thanks Xavier!  I'll let you know how it goes.

 

Thanks for responding!

 

Diane

0 Kudos
Message 3 of 3
(2,043 Views)