3112Views7Replies

Author Options:

Is it possible to make batch files take fractions into account? Answered

When you put a command to evaluate and equation, like (2/3)+1, the answer would just appear as 1. Even when you put an equation like (2/3+1)*3, where the answer is an integer 5, the answer would come out as 3. Any idea how to make batch files calculate the fractions together with the integers?

Tags:batch

Comments

The forums are retiring in 2021 and are now closed for new topics and comments.
0
Aosih
Aosih

11 years ago

Multiplying it by 1000 is a great idea! I'll think of a way to put it into the batch... I was trying to get the batch to calculate something for a game... The game goes like this... Pick 4 numbers from 1-10 (numbers can be repeated)... Using each number once (not more not less), and using only + - * /, we have to try and get the number 28... Some combinations are impossible though, so I was trying to make a batch which can calculate if it is possible to get 28...

0
lemonie
lemonie

11 years ago

Batch files run batches of commands they don't do math. What command are you using for this - (exact specific line) L

0
lieuwe
lieuwe

Answer 11 years ago

yes they do, i believe that with set /a abc=equation you can do math, i don't think that it takes fractions into acount, but you can just have an imaginary dot, like instead off 129.3664 you use 1293664....

0
lemonie
lemonie

Answer 11 years ago

That is running the SET command. You can put the SET command in a batch, but being in or out of a batch is irrelevant here. The question would have been better titled "Is it possible to make the MS DOS SET function take fractions into account?"

L

0
Jayefuu
Jayefuu

11 years ago

If you tell me what it is you want to do I'll do it for you in Perl or Python.

0
AlternateLives
AlternateLives

11 years ago

I would try using whole numbers that are larger than the numbers that you are using (for example, instead of 29.99 you use 2999) and then divide by 1/100 (in this case. add 1 zero for every number behind the decimal.)

0
Jayefuu
Jayefuu

11 years ago

What're you trying to do with your batch file?