Hi
I am having a tab delimited file
col1 col2 col3 col4
123 677 778 89.9999
222 677 778 989.999
223 777 778 989.999
when col2 first number equal to 6 ,then i have to multiply col4 with -1 (ie col4 * -1).
Please help me to write the batchscript.
I wrote the scrit its truncating the values.
Thanks
Gari
how to Multiply a decimal value with -1 in batch
Moderator: DosItHelp
Re: how to Multiply a decimal value with -1 in batch
Batch SET command does not support floating point arithmetic.
Re: how to Multiply a decimal value with -1 in batch
Why would you multiply by -1. All you have to do is put a negative sign in front of the number if you are multiplying by -1.
If you really want to try and multiply with floating point numbers then give Judago's Str_Math.bat file a try.
http://judago.webs.com/mathsbyteconversion.htm
If you really want to try and multiply with floating point numbers then give Judago's Str_Math.bat file a try.
http://judago.webs.com/mathsbyteconversion.htm
Re: how to Multiply a decimal value with -1 in batch
Could be done using string manipulation. If the first character is a minus then remove it. Otherwise prepend a minus.
Regards
aGerman
Code: Select all
if "%float:~,1%"=="-" (set "float=%float:~1%") else set "float=-%float%"
Regards
aGerman