For a script I was writing, I needed to work with large integers.

 

Example code in VBS was to compare very large numeric numbers:

-----------------------------------------

Dim LargestValue
LargestValue=0
AR = Array("134234","22342399999999999994","9","555555555577698","6","5")
For l = 0 to UBound(AR)
    If LargestValue < Int(AR(l)) then
       LargestValue = Int(AR(l))
    End If
Next
wscript.echo LargestValue

-----------------------------------------

 

As you can see 22342399999999999994 is the largest value and it should be returned as such. Well it does, almost...
However, it does not say (and that is what I would like!):
22342399999999999994

but it says:
2.23424E+19

As soon as a numeric value gets a certain size it converts it to x.xxxxE+y

Example code in VBS was to compare very large numeric numbers:

-----------------------------------------

@ECHO OFF
CLS
SETLOCAL ENABLEDELAYEDEXPANSION
SET LargestValue=0
FOR /F %%I IN (NUMBERS.TXT) DO (
 IF /I !LargestValue! LSS %%I (
  SET LargestValue=%%I
 )
)
ECHO !LargestValue!

-----------------------------------------

 

In this case it does return the largest value as I want...

 

So I thought, lets do it in batch. So before continuing I thought "let's do another test of creating an addition of very large numbers". The code would look like:

-----------------------------------------

@ECHO OFF
CLS
SETLOCAL ENABLEDELAYEDEXPANSION
SET NUMBER1=4611689999999999999
SET NUMBER2=500000
SET /A NUMBERTOTAL=%NUMBER1% ++ %NUMBER2%
ECHO %NUMBERTOTAL%

-----------------------------------------

 

now guess what the output was!....

 

it was:

Invalid number.  Numbers are limited to 32-bits of precision.

 

Man, this sucks!

Jorge

-------------------------------------------------------------------------------------------------
* This posting is provided "AS IS" with no warranties and confers no rights!
* Always test before implementing!
-------------------------------------------------------------------------------------------------