1.

Solve : Integer Overflow??

Answer»

I have an arithmetic process, that when expanded, looks like and returns as so:
Code: [Select]set /a var=5296128*432
-2007040000
The value should be 2287927296.

My confusion is in the fact that I can manually set a variable to this large NUMBER and echo it.
Code: [Select]set var=2287927296
echo %var%
2287927296
What gives? Thanks.Numbers are limited to 32-bits.

In your second example your are assigning a string to the variable.
Quote from: oldun on August 10, 2009, 02:41:37 AM

Numbers are limited to 32-bits.

That WOULD make sense. 32-bit signed integers(−2,147,483,648 to +2,147,483,647)

Quote from: oldun on August 10, 2009, 02:41:37 AM
In your second example your are assigning a string to the variable.

This was my hangup, I didn't understand that the value was stored as a string when I specified a number. Thanks.Quote from: oldun on August 10, 2009, 02:41:37 AM
Numbers are limited to 32-bits.
depends on the architecture as well as LANGUAGE support....

@OP, use a BETTER language than cmd.exe for doing maths task.... the next best thing beside batch natively is vbscript...

Code: [Select]C:\test>type test.bat
@echo off
set /a var=5296128*432
echo %var%

C:\test>type test.vbs
a = 5296128*432
WScript.Echo a

C:\test>test.bat
-2007040000

C:\test>cscript /nologo test.vbs
2287927296

set /a sets a numeric variable, set on its own ASSIGNS a string.



Discussion

No Comment Found