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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top