Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Mattis95
- Posts: 8
- Joined: 12 Jan 2012 13:04
#1
Post
by Mattis95 » 23 Feb 2012 07:56
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?
-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#2
Post
by Ed Dyreen » 23 Feb 2012 08:01
'
DOS doesn't support floats have to be emulated.
-
Mattis95
- Posts: 8
- Joined: 12 Jan 2012 13:04
#3
Post
by Mattis95 » 23 Feb 2012 08:03
It worked, but if I want to
add 50% of %hi% to %hi%?
-
orange_batch
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
-
Contact:
#5
Post
by orange_batch » 23 Feb 2012 12:23
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).
-
Aacini
- Expert
- Posts: 1913
- Joined: 06 Dec 2011 22:15
- Location: México City, México
-
Contact:
#6
Post
by Aacini » 23 Feb 2012 18:48
@Mattis95: May I suggest you to post better/clearer topic titles for your questions?
Regards...
-
Mattis95
- Posts: 8
- Joined: 12 Jan 2012 13:04
#7
Post
by Mattis95 » 24 Feb 2012 10:08
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"?