Question

I need to create a batch file that is able to take a %FREEMEMORY% variable that represents a number and multiply that variable by 0.09 and set the product of that equation as another variable using this name: %MEMORYTOUSE%. I need to be able to round the product down to the nearest whole number.

I just need to know how to multiply any number by 0.09 and then round it down to the nearest whole number.

Était-ce utile?

La solution

There are no decimals in batch arithmetic. All the calcs are with 32 bit integers (31 bit numbers plus a sign bit), with data values in the range -2147483648 to 2147483647. So what you need is

set /a "memoryToUse=%freeMemory% * 9 / 100"

Of course, limited to the indicated range of values.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top