Fonte Matemática em arquivos em lote do NT
Workarounds: 32-bit
Workarounds for the 32-bit limitation include:
dividing by 1000 (or any power of 10) by chopping off the last (3) digits
splitting up the numbers into separate decimal digits and perform all the math and carry logic "manually"
other scripting languages
Workaround #1 can be used to add up disk space, for example:
The trick is that each (big) number is treated as strings, then the rightmost 6 characters (digits) are chopped off, and only then the result is treated as a number.
This is a rather crude workaround, as it "rounds" all numbers before doing the math. Adding half a MegaByte for each subdirectory (%Count% / 2) to %Total% does compensate for the truncations, though, so the grand total is more accurate than the individual numbers. Note that the numbers don't represent "real" MegaBytes (1024 x 1024) buth rather Million Bytes (1000 x 1000).
Workaround #2 is perfectly demonstarted by Brian Williams' batch files:
Perfect, but quite complex.
Workaround #3, other scripting languages, is self-explanatory.
Workarounds: integers
There are no real workarounds that allow floating point math, except using other scripting languages.
The only exception may be if you have a limited and fixed number of decimals (e.g. 2), then you can just multiply everything by 100.
To display a decimal delimiter in the end results, concatenate the ineger divide by 100, followed by the decimal delimiter, followed by the modulo divide by 100:
SET Whole = Result / 100 SET "Fraction = Result %% 100" SET Result=%Whole%.%Fraction%
This may break on the 32-bit limit, though.
In general, for floating point math I would recommend using other scripting languages.