LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

decimal to hex

hi... I´m creating a program... and I want to convert my decimal numbers in hex numbers, but with the same number.. for example... I need trasform 149(dec) in
149(hex)... I know that 149 dec is equivalent to 95 hex.. but I need transform any number dec.. in the same hex.. 138dec to 138 hex.......
thanks..
0 Kudos
Message 1 of 4
(3,494 Views)
Hi,
You can do it in following way:
1. First convert your decimal number to its string representation with "Functions->String->String/Number Conversion->Number to decimal string.vi"
2. Then convert this string to the hex number with "Functions->String->String/Number Conversion->Hexadecimal string to number.vi"

The example is attached.

Good luck.

Oleg Chutko.
Message 2 of 4
(3,494 Views)
I am curious if you are doing this so that the panel display will be entered
in hex. If so you need to right click the panel control and select 'format
precision' and select hexadecimal.

"Jav" wrote in message
news:506500000008000000F1940000-1042324653000@exchange.ni.com...
hi... I´m creating a program... and I want to convert my decimal
numbers in hex numbers, but with the same number.. for example... I
need trasform 149(dec) in
149(hex)... I know that 149 dec is equivalent to 95 hex.. but I need
transform any number dec.. in the same hex.. 138dec to 138 hex.......
thanks..
Message 3 of 4
(3,494 Views)
Hello Jav

Jav wrote:
> hi... I´m creating a program... and I want to convert my decimal
> numbers in hex numbers, but with the same number.. for example... I
> need trasform 149(dec) in
> 149(hex)... I know that 149 dec is equivalent to 95 hex.. but I need
> transform any number dec.. in the same hex.. 138dec to 138 hex.......
> thanks..

The method I'd chose would be over a string-conversion.

Use the "To Decimal" Function to convert the Number to a String and feed
this string to a "From Hexadecimal". This will interpret the decimal
sting as hexadecimal, which is just waht you want.

you can get an example from
http://www.marco.tedaldi.net/labview/vis/
(dec_hex.vi it's labvie 4.1 which should automatically get converted to
your version).

I think it isn't
very fast. So, if you're using the conversion for much
data or in a tight loop, you should try another way with some math
("Quotient & Reminder" could help).

bye

Marco
0 Kudos
Message 4 of 4
(3,494 Views)