LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert "8 byte, 2's complement, Least significant byte first" number into a decimal number?

Solved!
Go to solution

 

Hi, I am trying to analyze the readings from SRS RGA, and the output is in hex format (four byte integers, 2’s complement format, Least Significant Byte first).

Any help in converting this into a decimal number would be greatly appreciated.

0 Kudos
Message 1 of 29
(4,723 Views)

So I assume you have a string with this data.  Just use the Unflatten From String to convert the string to an I32.  There in an input to that function to set the endian.  You may have to set that to Little Endian.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 29
(4,708 Views)

 

Little Endian.png

Thanks for the reply.

I can see the binary string being converted into an 8 byte, little-endian (least significant byte first) integer value. 

Since my output is in hex, I guess I will have to convert that into a binary string first, before I can convert into an integer. 

How about the 2's complement part, don't I have to take care of that before I can do anything?

Thanks

 

0 Kudos
Message 3 of 29
(4,691 Views)

So you are saying you have an 8 character string of hex characters, and that represents a 4-byte integer?

 

You don't need to worry about the 2-'s complement first.  Get the 8 hex characters converted to 4 bytes first.  Then use CrossRulz's example to convert those 4 bytes to an I32 integer.

0 Kudos
Message 4 of 29
(4,682 Views)

Or is it an I64?  I somehow skipped over the "8 byte" in my head before.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 29
(4,677 Views)

According to the user's manual of the SRS RGA, the output is in "hex format (four byte integers, 2’s complement format, Least Significant Byte first)."

0 Kudos
Message 6 of 29
(4,675 Views)

To be exact, please see the quote from RGA Manual.

"Ion signals are represented as integers in units of 10-16 Amps, and transmitted directly in hex format (four byte
integers, 2’s complement format, Least Significant Byte first) for maximum data throughput."

0 Kudos
Message 7 of 29
(4,672 Views)

Why does your subject line say "8 byte"?  That is what is confusing things.

 

Atttach a link to the manual.

0 Kudos
Message 8 of 29
(4,665 Views)

That's a type and sorry about that. It is 4 byte.

Here's a link to the manual

http://www.thinksrs.com/downloads/PDFs/Manuals/RGAm.pdf

0 Kudos
Message 9 of 29
(4,658 Views)
Have you tried the driver that is available?
0 Kudos
Message 10 of 29
(4,650 Views)