LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with exadecimal conversion

Hi all, i have this problem, i try to convert decimal number to exadecimal, concatenate with other exadecimal and reconvert on decimal but don't work.

the result number is not correct, where i wrong

0 Kudos
Message 1 of 16
(1,778 Views)
  1. You should fix your keyboard. It seems the "h" key does not work right.
  2. A toplevel loop needs a wait. No need to repeat the same calculations millions of time per second.
  3. Don't make both inputs the same value to avoid hidden mistakes. You need to be able to tell that the order is correct in the output.
  4. You should learn about numeric representations. My guess is that the two controls should be U8 and the casting back should be to U16.

altenbach_0-1670689489532.png

 

If you really want to merge two 32bit integers, the constant wired to typecast should be 64bit, right? Did you notice the coercion dot?

 

altenbach_0-1670689884567.png

 

Typecast is a very dangerous function for the newbie. There is no error handling and given incorrect inputs can give you completely meaningless outputs. You need to make absolutely sure that the inputs match the output type down to the bit. In your case, you tried to cast a 8byte hex string to a 4 byte numeric. Round peg, square hole!

 

 

0 Kudos
Message 2 of 16
(1,749 Views)

@Simx7719 wrote:

i try to convert decimal number to exadecimal, concatenate with other exadecimal and reconvert on decimal but don't work.


I've never heard of an "exadecimal" number, nor has Google (which told me about "hexadecimal", which I do know about).  Unfortunately, I do not have LabVIEW 2022 installed on any of my PCs, so I'm going to proceed assuming that @Smix meant "hexadecimal".

 

LabVIEW has two functions on the Data Manipulation sub-Palette of the Numeric Palette that can Split Numbers (integers, from 16, 32, or 64 bits) into unsigned integers of 8, 16, or 32 bits (you can technically ask it to split an 8-bit number, which it treats as a 16-bit number with the top 8 bits all zero).  Similarly, there is also Join Numbers.

 

The important thing to realize is how signed integers are represented (in LabVIEW and most computers).  Consider (say) a 16-bit number, let's say +6.  In decimal, it is 6 (leading zeros are "silent"), and in hex it is 0x0006.  What about -6?  Signed integers use the most-significant bit as a "sign" bit, set to 1 if the number is negative, with the additional "rule" that a number and its negative add to 0.  If you work it out, you can find that -6 is 0xFFFA (or 0b1111111111111010).  [Try doing the arithmetic in binary, recalling +6 is 0000000000000110 --adding from right to left, 0+0 = 0, 1 + 1 = 0 carry 1, 0 + 1 + carry = 0, 1 + 0 + carry = 0 + carry, 1 + 0 + carry = 0 + carry, until you end with all zeros and a "left-over" carry (which you throw away), showing 6 + (-6) = 0.  So you need to be aware of this and think about it when dealing with signed quantities.

 

I suggest writting a little VI for yourself that lets you enter a 16-bit number as a signed integer (I16), wire it to an U16 indicator (to see how the sign bit works -- display it both in Hex and Decimal), then try splitting it and viewing the splits.  Once you understand Splits, work on Joins, and before you know it, you'll realize how to do what you want to do.

 

Bob Schor

 

 

 

0 Kudos
Message 3 of 16
(1,739 Views)

thank you very much i understood my many mistakes, i understood what to go to study well THANK YOU!!!

0 Kudos
Message 4 of 16
(1,732 Views)

Just for the fun of it, hexadecimal is actually a macaronic word, it consists of the Greek hexa and the Latin decim. The pure latin version would be sexadecimal but that dtd likely not make it because of its to close resemblance with sex.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 16
(1,683 Views)

@rolfk wrote:

Just for the fun of it, hexadecimal is actually a macaronic word, it consists of the Greek hexa and the Latin decim. The pure latin version would be sexadecimal but that dtd likely not make it because of its to close resemblance with sex.


As if numbers aren't sexy enough...

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 16
(1,648 Views)

... and GPS made "sextants" obsolete. 😄

0 Kudos
Message 7 of 16
(1,620 Views)

@rolfk wrote:

Just for the fun of it, hexadecimal is actually a macaronic word, it consists of the Greek hexa and the Latin decim. The pure latin version would be sexadecimal but that dtd likely not make it because of its to close resemblance with sex.


I don't think that's the reason, because we refer base 60 (for times and angles) as sexagesimal.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 8 of 16
(1,596 Views)

@paul_cardinale wrote:

@rolfk wrote:

Just for the fun of it, hexadecimal is actually a macaronic word, it consists of the Greek hexa and the Latin decim. The pure latin version would be sexadecimal but that dtd likely not make it because of its to close resemblance with sex.


I don't think that's the reason, because we refer base 60 (for times and angles) as sexagesimal.


But it's a purely academic system. I have never seen anyone really use it in any way. And with 60 different symbols to come up with it looks a bit Chinese to me. 😁 More than 16 starts to get a bit difficult to learn and manage.

Rolf Kalbermatter
My Blog
0 Kudos
Message 9 of 16
(1,593 Views)

@Simx7719 wrote:

Hi all, i have this problem, i try to convert decimal number to exadecimal, concatenate with other exadecimal and reconvert on decimal but don't work.

the result number is not correct, where i wrong


"Exa" means 10^18.  So I guess "exadecimal" would be base quintillion and ten (i.e. 1,000,000,000,000,000,010).  Converting to "exadecimal" would certainly be very ambitious, but I'm afraid even Unicode won't help you.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 10 of 16
(1,588 Views)