Computer Hope

Microsoft => Microsoft DOS => Topic started by: Woodman on January 15, 2008, 03:24:32 PM

Title: SET /A Command
Post by: Woodman on January 15, 2008, 03:24:32 PM
Win.XP Home SP.2

How can I get the Set/a command to return the complete value???

Example:

@echo off
cls

set a=1029

set /a b=%a%/2

echo %b%

returns 514 which should (hopefully) be 514.5

Where have I got it wrong please???

Thanks
Title: Re: SET /A Command
Post by: gpl on January 15, 2008, 05:02:14 PM
You didnt go wrong .. you can only do integer maths, which means that any fraction is dropped off

You could try multiplying your number by 10, doing the division and inserting a '.' to the left of the rightmost digit.
Title: Re: SET /A Command
Post by: Woodman on January 15, 2008, 05:57:53 PM
Quote from: gpl
you can only do integer maths, which means that any fraction is dropped off

Thank you, I must have missed that very important condition in the SET/? display which I will re-read.