Do you guys know a way to determine if a string, when converted to a numerical value, can be put inside for example a 32-bit integral value or not? For example, the user provides ?65535? and you should determine if this string, after having been converted to a numerical value, can be put inside a 16-bit register/memory! Or for example, when the user provides ?000000000000012?, the procedure should be able to determine if it can be put inside a 32-bit register or whatever!

I have tried different ways around it and found the leading zeros the most annoying factors in determining if the string can be put in a certain range of a numerical value but at the same time, it would be a good feature for the procedure to be able to handle those zeros.

The goal for me is not to go through the actual process of converting the string to a numerical value. I?d appreciate helps/hints.

I have tried different ways around it and found the leading zeros the most annoying factors in determining if the string can be put in a certain range of a numerical value but at the same time, it would be a good feature for the procedure to be able to handle those zeros.

The goal for me is not to go through the actual process of converting the string to a numerical value. I?d appreciate helps/hints.

I don't see any problem with the zeroes.

0 multiplied by 10 a dozen times makes 0.

You just have to watch if after the multiplication, the value becomes larger than 32-bit after "mul". (edx is different from 0 or -1).

0 multiplied by 10 a dozen times makes 0.

You just have to watch if after the multiplication, the value becomes larger than 32-bit after "mul". (edx is different from 0 or -1).

It's pretty easy to eat the leading zeros and the stored numerical value will be smaller. And sooner or later you will need a function to convert strings to integers anyway. You only have to write it once!

If you are using a fixed size buffer to hold the numeric string,

make it one more than a multiple of four characters.

Example for asciiz make it 13 or 17 bytes 12+1 or 16+1

then load one dword at a time, starting at offset 8 or 12

and compare to the dword 30303030h if not equal then

at least one character is non zero.

Another issue is what base are the numbers,

Base 10 (decimal) or Base 16 (hexadecimal) ?

If the range is the unsigned integers then:

For base ten if the number is <= 8 digits then it will fit,

if 9 digits then if the most significant digit is 1,2,3 it will also.

For base 16 if it is <= 8 hexdigits it will fit.

make it one more than a multiple of four characters.

Example for asciiz make it 13 or 17 bytes 12+1 or 16+1

then load one dword at a time, starting at offset 8 or 12

and compare to the dword 30303030h if not equal then

at least one character is non zero.

Another issue is what base are the numbers,

Base 10 (decimal) or Base 16 (hexadecimal) ?

If the range is the unsigned integers then:

For base ten if the number is <= 8 digits then it will fit,

if 9 digits then if the most significant digit is 1,2,3 it will also.

For base 16 if it is <= 8 hexdigits it will fit.

If you are trying to compress strings of numerical ASCII digits, while keeping leading 0s, you could consider the following. However, in some cases, you would not be gaining much if anything.

1- Convert the ASCII digit to binary. this will always fit in the lower 4 bits of the byte.

2- If an identical digit follows immediately, increment the upper 4 bits of the byte (until it would equal a maximum of 15).

3- Store the byte.

4- Terminate the compressed string with 0FFh (which would be impossible to produce with this method).

For example, 65535 would become 06, 15, 03, 05, FF

and 000000000000012 would become C0, 01, 02, FF

Have fun

Raymond

1- Convert the ASCII digit to binary. this will always fit in the lower 4 bits of the byte.

2- If an identical digit follows immediately, increment the upper 4 bits of the byte (until it would equal a maximum of 15).

3- Store the byte.

4- Terminate the compressed string with 0FFh (which would be impossible to produce with this method).

For example, 65535 would become 06, 15, 03, 05, FF

and 000000000000012 would become C0, 01, 02, FF

Have fun

Raymond