LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

integer to word

i've got an number between -32767 and 32768.
i want to convert this number to an hex number between 0000 and ffff. which is the easiest way?
0 Kudos
Message 1 of 6
(2,693 Views)
WeberM;

Represented your number with a Long and then add 32767 to your number. If you want to see the number in HEX, right-click the indicator, select "Format & Precision...", and change the format to Hexadecimal.

Regards;
Enrique
www.vartortech.com
0 Kudos
Message 2 of 6
(2,693 Views)
thanks for your comment.
your solution is good for a indication on the frontpanel but i had to convert the value into bits and work with it.
do you know any other way to solve my problem?
0 Kudos
Message 3 of 6
(2,693 Views)
WeberM;

The boolean menu in the function palette includes a function that allows you convert a number into an array of bools. Also, you can use any of the other boolean function to manipulate the number at the bit level.

Enrique
www.vartortech.com
0 Kudos
Message 4 of 6
(2,693 Views)
WeberM wrote in news:50650000000800000064EA0000-
1079395200000@exchange.ni.com:

> i've got an number between -32767 and 32768.
> i want to convert this number to an hex number between 0000 and ffff.
> which is the easiest way?

16 bit integers have range -32768 to 32767

I guess you want
Decimal Hex
0 0000
32767 7FFF
-32768 8000
-1 FFFF
Which is just different representations.
I base my answer on this, if this is not what you want please repost.

Solution one:
You could just set your numeric indicator to hexadecimal representation
Right click and select "Format & Precision"
This will not give you leading zeroes

Solution two:
Use the "Format into String" function
(Function palette->String-
>Format into String)
Wire your number to input "input 1"
Wire a string constant containing "%04x" to input "Format string"
The output "Output String" will give you the hex number.

Hope this helps
--
Rolf
0 Kudos
Message 5 of 6
(2,693 Views)
So far, it is not obvious what you want. Could you explain your requirements in a few more sentences?

There is one slight problem: -32767..32768 is a signed integer, while 0000..FFFF is an unsigned integer (0-65535). Of course we could just assume that you want to simply indicate the bit pattern of the I16 in hex. (Convert will often not work because the ranges are different). Please clarify.

Internally all numbers are binary, so there is no conversion needed. You can select how it should be shown cosmetically on the UI by selecting the proper formatting. In a later answer, you seem to imply that you need access to individual bits. This can be done by converting it to a size 16 boolean array using 4.x typecasting.

The attached code image shows s
ome of the methods. (Rolf also mentioned formatting into string, which is not shown here).
0 Kudos
Message 6 of 6
(2,693 Views)