Working with Numbers Greater than 2 GB
Keywords: numbers greater than 2,000,000,000
Question:
I have run into a new problem. I finally took the time to run my program against all of the file servers in question. The size of all of the files should be 5GB+ (in other words 5,000,000,000 bytes). Instead, when I print the total accumlator, I receive:-667724294
This will typically happen in C coding if you are not using a long variable. Is there a limitation in Winbatch to counting such a high number?
Answer:
Yes. WinBatch integer mode has a limit of just over 2GB.2 proposed workarounds.
- As soon as you get a number, divide it by 1024 to convert it to K and use that instead.
Or divide it by 1024000 to convert to GB.
OR...
- As soon as you get a number multiply it by 1.0 to make it a floating point number.
Article ID: W14145Filename: Working with Numbers Greater than 2GB.txt