Programmatically Converting Hexadecimal Strings into Doubles

Updated Dec 15, 2022

Environment

Software

  • LabVIEW

How can I turn my string into a double? My GPIB instrument returns a hexadecimal string and I would like to view them as doubles.

There are three methods to converting hexadecimal strings depending on the need for byte or bit swapping:
 

Method 1: If no bit swapping is required

  1. Input hexadecimal string
  2. Convert hexadecimal string into a number using Hexadecimal String to Number VI
  3. Convert number to double precision float
  4. Display result

Method 2: Bit Swapping is necessary

  1. Input hexadecimal string
  2. Read each hexadecimal value using a For Loop and String Subset VI
  3. Convert each hexadecimal value to boolean (bit)
  4. Build a boolean array
  5. Reverse boolean array (reverse bits)
  6. Build reversed array
  7. Convert boolean array to number
  8. Convert number to double                             
                                                                         

Method 3: Byte Swapping is necessary

  1. Input hexadecimal string
  2. Turn hexadecimal string into an array
  3. Reverse array
  4. Turn array back into hexadecimal string
  5. Convert hexadecimal string to number
  6. Convert number to double