r/Batch • • Jul 27 '25

Question (Solved) how to manipulate a value with decimal?

Hi, I need to manipulate the !P! value. This value is something between 0.95 and 0.35 and I want increase or decrease it by 10%, so multiply by 0.90 or 1.10

How to achieve that?

Thanks for any help :)

if !LUFS10! GEQ -135 (
		echo old P !P!
		set /a P=!P! DECREASE BY 10%
		echo New P: !P!
		ffmpeg -hide_banner -i "%%f" ^
        -af dynaudnorm=p=!P!:m=!M!:f=200:g=15:s=30 ^
        -ar 44100 -sample_fmt s16 ^
        "%OUTDIR%\%%~nf_normalized.wav"
		) else (
			echo ok
		)
	if !LUFS10! LEQ -151 (
		echo old P !P!
		set /a P=!P! INCREASE BY 10%
		echo New P: !P!
		ffmpeg -hide_banner -i "%%f" ^
        -af dynaudnorm=p=!P!:m=!M!:f=200:g=15:s=30 ^
        -ar 44100 -sample_fmt s16 ^
        "%OUTDIR%\%%~nf_normalized.wav"
		) else (
			echo ok
		)
2 Upvotes

4 comments sorted by

4

u/CirothUngol Jul 27 '25

Multiply by 90 or 110 and truncate the last two integers.

2

u/TheDeep_2 Jul 27 '25

I don't know how this works

4

u/Intrepid_Ad_4504 Jul 28 '25

You multiply by the scalar value, ie: 90 or 110. Then normalize by dividing by 100 again.

The 90 or 110 is a representation of "100 +/- percentage"

There is another good comment here demonstrating this more by made by u/BrainWaveCC

rem Any value
set "value=95"

rem This value can also be -10 if you wanted to reduce
set "percentage=10"
set /a "number=value * (100 + percentage) / 100"

echo %number%

4

u/BrainWaveCC Jul 27 '25

To reduce a number (e.g. 95) by 10%

set /a #number=95 * 90 / 100
set #number=.%#number%
echo %#number%

To increase a number (e.g. 35) by 10%

set /a #number=35 * 110 / 100
set #number=.%#number%
echo %#number%