# LabVIEW

cancel
Showing results for
Did you mean:

## Converting a floating 32 bit hex number into its decimal equivalent

Iam new to labView, and iam trying to convert a 32 bit floating hex number into its dec equivalent in labview 8.2, any suggestions?

Message 1 of 9
(3,660 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

A  numbers base representation is really just a visual thing in LabVIEW.

If you're looking at a number on the front panel and it's displayed in hex, you can easily change it to display it in decimal, octal or binary. The number itself has the same value regardless of it's representation. The math functions will work.

To change how it is displayed, right click on the control/indicator and select 'Visible>Radix'. This will display the numbers base on the front panel. You can now use the operating tool (the little hand) to click and select the different bases for display.

If this isn't what you're trying to do, can you provide a few more details like converting a hex string to a number maybe?

Ed

Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 2 of 9
(3,657 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

Thanks, I didn't know it was that easy to change between number formats,  The other thing Iam trying to do i should have gave more detail...  Iam polling this register that gives me two 16 bit floating numbers,  what iam trying to do is combine both numbers and convert from floating format to fix interger,  for example i get a one hex value as 44C8 which is 17608dec and then the low value is 3339hex = 13113dec,  using a calculator from IEEE-754 the dec equivalent when combined is 1601.11.  I was wondering if there was a way to do this in  labview.  The link to the IEEE site is http://babbage.cs.qc.edu/IEEE-754/32bit.html  "44C83339"

Message 3 of 9
(3,654 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

On the block diagram, look in the 'Numeric' palette and there are a couple sub palettes with more funations.

The first sub palette on the top right is a bunch of Conversion functions. There's one to convert any numeric format to any other format. You'll want to use the 'U16' to get you floating point number to an unsigned 16 bit integer.

Then look in the next sub palette down in the Numeric palette for some 'Data Manipulation' functions. The second one on the bottom row is "Join Numbers". Connect the two new U16s and you'll get the number you're looking for.

Ed

Message Edited by Ed Dickens on 12-18-2006 06:33 PM

Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 4 of 9
(3,652 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

Sorry Ed, your solution isn't exactly correct.  The original question was to join two hex numbers (decimal values) and form a floating point number (DBL).  I don't know the exact formula, but from the website given by J_Little, the IEEE-754 spec says that bits 23 through 30 are the exponent, bits 0 through 22 are the significand, and bit 31 is the sign.  So you have to first join the numbers using the Join fuction as Ed has shown, then you have to split up the bits to form the exponent and significand.  I tried this but was unable to get the correct significand according to the website.  Maybe someone else can chime in and give the correct formula or algorithm to convert a 32 bit number into a floating point number according to the IEEE-754 spec.
- tbob

Inventor of the WORM Global
Message 5 of 9
(3,633 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

Well, simply using a type cast on the 32bit value gives 1601.6007

Is that sufficiently accurate?

Rod.

Message Edited by Rod on 12-19-2006 04:55 PM

Message 6 of 9
(3,627 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

I just went to the web site you showed, and entered 44c83339 into the Hexadecimal Representation box, and clicked compute. To 4 d.p. it gave 1601.6007, [same as LabVIEW gave] so I'm not sure where your .11 came from.

BTW the page is a very useful means of seeing how floats are represented in binary.

Rod.

Message 7 of 9
(3,615 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

Looks like tbob caught my mistake and Rod beat me to the correct solution.

Thanks Guys,

Ed

Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
Message 8 of 9
(3,612 Views)

## Re: Converting a floating 32 bit hex number into its decimal equivalent

That works great, Thanks for all the help!!

Cheers
Message 9 of 9
(3,605 Views)