Jump to content

Convert a Decimal String to a Hexadecimal String


jaehov

Recommended Posts

Posted

Hello Code Gurus

I would like to convert a labview decimal string, e.g. "242992472391692" into an equivalent HEX String "DD001800000C"

Can someone show me how to do this?

thanks

new kid on the block :)

Posted

Use the same general approach that I used in the example I posted in your other thread but modify the algorithm. In this case you would only be working with a single array and you would need to work with two elements of the array at one time. You would also need to work with nibbles of data. Cycle through the array picking 16 bits of data at a time from the digits and then accumulate the new hex string. In this conversion you would not need to generate the intermediate byte array as you could go directly to the hexadecimal string.

Posted

QUOTE (jaehov @ Feb 17 2009, 10:18 PM)

I would like to convert a labview decimal string, e.g. "242992472391692" into an equivalent HEX String "DD001800000C"

Here are the steps (LabVIEW isn't currently running).

Use a string to numeric conversion VI:

dectonum.gif

With a I64 (or U64) as datatype.

Now you have two options

1.Use a Number to Hexadecimal string:

numtohex.gif

2.Display the 'number' and change it's representation to HEX.

Ton

Posted

QUOTE (Ton @ Feb 17 2009, 03:39 PM)

Here are the steps (LabVIEW isn't currently running).

Use a string to numeric conversion VI:

dectonum.gif

With a I64 (or U64) as datatype.

Now you have two options

1.Use a Number to Hexadecimal string:

numtohex.gif

2.Display the 'number' and change it's representation to HEX.

Ton

This will work nicely provided he has 64 bit integers. Based on an earlier post of his he needed to do this on without 64 bit integers for numbers larger than 32 bit integers. That was the reason I was suggesting converting the string to a byte array and processing that. That solution will work for abitrarily large numbers.

Posted

QUOTE (Mark Yedinak @ Feb 17 2009, 04:54 PM)

This will work nicely provided he has 64 bit integers. Based on an earlier post of his he needed to do this on without 64 bit integers for numbers larger than 32 bit integers. That was the reason I was suggesting converting the string to a byte array and processing that. That solution will work for abitrarily large numbers.

Yes. I am in the labview 7.1 environment. So I am without the use of the Labview U64 capability.

Posted

QUOTE (jaehov @ Feb 17 2009, 06:22 PM)

Yes. I am in the labview 7.1 environment. So I am without the use of the Labview U64 capability.

Here is an example, hope this helps!

Posted

QUOTE (jaehov @ Feb 19 2009, 11:04 AM)

GREAAAAT! This works like a charm! Thanks for EVERYONE

I guess this is what you were looking for!

Just be careful, there is a limitation on conversion. It is not all 64 bits. You can find more info on NI web site about extended precision.

Posted

Here is a slightly different version which would solve his original issue of converting a number with greater than 32 bits on an earlier version of LabVIEW that did not have U64 integers. This vi will take an arbitrarily long decimal string and convert it to a hexadecimal string.

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.