Jump to content

Convert a Decimal String to a Hexadecimal String


jaehov

Recommended Posts

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.

Link to comment

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

Link to comment

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.

Link to comment

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.

Link to comment

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.

Link to comment

Join the conversation

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

Guest
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.