Page 1 of 1
50%
Posted: 23 Feb 2012 07:56
by Mattis95
I want to create a variable, then remove/add 50% of itself to itself, I thought it should work with this, but it doesn't:
Why doesn't it work and how can I make it work?
Re: 50%
Posted: 23 Feb 2012 08:01
by Ed Dyreen
'
DOS doesn't support floats have to be emulated.
Re: 50%
Posted: 23 Feb 2012 08:03
by Mattis95
It worked, but if I want to
add 50% of %hi% to %hi%?
Re: 50%
Posted: 23 Feb 2012 08:23
by foxidrive
Is this any good?
Code: Select all
@echo off
set hi=60
set /a hi=hi*3/2
set hi
pause
Re: 50%
Posted: 23 Feb 2012 12:23
by orange_batch
Code: Select all
@echo off
set hi=60
set /a hi=hi*30/2
if "%hi:~-1%"=="0" (set hi=%hi:~,-1%) else set hi=%hi:~,-1%.%hi:~-1%
set hi
pause
Returns decimal number to tenths (unless number is an integer).
Re: 50%
Posted: 23 Feb 2012 18:48
by Aacini
@Mattis95: May I suggest you to post better/clearer topic titles for your questions?
Regards...
Re: 50%
Posted: 24 Feb 2012 10:08
by Mattis95
Aacini wrote:@Mattis95: May I suggest you to post better/clearer topic titles for your questions?
Regards...
Yea, maybe I should have called it... "Add 50% of itself to itself"?