Page 1 of 1
how to get 2.5 from 5/2
Posted: 11 May 2017 05:52
by suda
num=5/2;
ans="{num,numberformat,0.0}";
//I want 2.5 as answer ,but returned value is 2.0
//Teach me how to get 2.5 ,please.
Re: how to get 2.5 from 5/2
Posted: 11 May 2017 06:11
by Bingwu
Hello Suda!
Make a point behind the divisor:
num=5/2.;
regards
Peter
Re: how to get 2.5 from 5/2
Posted: 11 May 2017 07:22
by suda
Soon answer, Thank you!
I could get 2.5.
5/2. is Hidden function?
Recently i found "old_global_....."!
I think this function is good.
Re: how to get 2.5 from 5/2
Posted: 11 May 2017 07:54
by Bingwu
Hello Suda!
I am myself desperate at this "problem"! An official documentation or help is not known to me.
After a long search I found this post:
http://automagic4android.com/forum/view ... oint#p8246
regards
Peter
Re: how to get 2.5 from 5/2
Posted: 12 May 2017 14:24
by suda
Certainly, Strange...
"5/2 is 2.5" is simply than "5/2 is 2".
I think so.
For a long search, thank you.
Re: how to get 2.5 from 5/2
Posted: 15 Jun 2017 15:18
by Augugusto
The problem is that if you divide using integers it asumes that the output will be an integer so it deletes the decimals. If you add a '.' or '.0' after at least one of the numbers, it predicts the result as a float and you get the decimals
Edit: if you were using variables (or if you want to) I think you can just put "(float)" in front of one of the parts of the division
Re: how to get 2.5 from 5/2
Posted: 12 Sep 2017 02:39
by suda
Thank you!
In short, for example, when dividing, if you want decimal values, add ". 0" somewhere in the calculation formula. Is that it? It is okay.
I am using google translator. It became easy.