# LV 7.1 Convert a Decimal String "1234567899" to an Integer equivalent

## Recommended Posts

Hey techies

I am working with a pre-existing test tool with LV 7.1

I need to convert a Decimal String "1234567899" to an Integer equivalent (no truncation or other formatting)

Essentially I want the string "1234567899" to be converted to the Integer (1234567899)

I know in LV 8 this would be a breeze with U64. But how can I perform get same result in LV 7.1 ?

thanks

The new guy on the block

QUOTE (jaehov @ Feb 14 2009, 11:02 AM)

Essentially I want the string "1234567899" to be converted to the Integer (1234567899)

I know in LV 8 this would be a breeze with U64. But how can I perform get same result in LV 7.1 ?

Umm, that number fits fine in an I32. Assuming you are really having a problem, why not use DBLs? Just because it's not limited to integers doesn't mean its a bad choice for them if U32 is too small.

QUOTE (jdunham @ Feb 15 2009, 01:22 AM)

Umm, that number fits fine in an I32. Assuming you are really having a problem, why not use DBLs? Just because it's not limited to integers doesn't mean its a bad choice for them if U32 is too small.

i actually got the number wrong, its longer than that. Try "12345678991234567899"

Without using a different data type such as a double then your only real option is to handle 64 bit integers yourself. You would have to do this by using two 32 bit integers and creating your own methods for operating on those values. this would be a non-trivial exercise but if you must have them in integer format this is one of your only real alternatives. Much more memory intensive but possibly easier to work with and more extensible would be to store each digit of the number as an element of a byte array. Again, you have to create your own methods for operating on the numbers but they would be fairly straight forward to implement. Think back to your early days of learning math.

Here is a simple example for adding two large numbers. It should give you a good idea of how to proceed. If you will be doing more operations with larger numbers, or large number of numbers then you may need to spend some time optimizing the code for efficiency.

## Join the conversation

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
×