Re: Cannot get percentage?
You have to force float calculations by including a number with a decimal point.
Try a/b*100.0
Re: Cannot get percentage?
Netninja is right, but you need to make sure MMF understands that the values are floating point values before the division occurs.
Try ((a*1.0)/(b*1.0))*100
Re: Cannot get percentage?
just adding 0.0 at first should be enough.
Re: Cannot get percentage?
a*100.0/b is the simplest...
the ".0" forces it to use decimal places in the calculation, and the ordering means you don't have to add any extra "*1.0" or "+0.0".
Re: Cannot get percentage?
Taking this a bit farther... is there a way to show only two digits to the right of the decimal?
Re: Cannot get percentage?
floor(NUMBER * 100) / 100.0
Re: Cannot get percentage?
Won't this simply drop the value's RIGHT of the decimal point?
Re: Cannot get percentage?
Quote:
Originally Posted by Tuna
Won't this simply drop the value's RIGHT of the decimal point?
well unless i screwed something up:
1.23456 -> 123.456 -> 123 -> 1.23
so yes it technically does get rid of them but i don't think mmf has a printf/sprintf-like function
Re: Cannot get percentage?
Thanks for your assistance xyzzy...
I'm doing Floor(hits/tries)
or more accurately
set text to str$(floor(value("hits")*100.0/value("tries")))+"%"
I was getting values with 5 decimal places to the right of the decimal without the floor function. With it, I'm getting whole percentages only.