# How to get the percentage of two counters without decimal ?

• 5th May 2018, 05:30 PM
MagnetoX
How to get the percentage of two counters without decimal ?
I need to find value Counter as a percentage of  Counter 2 value. Ive got three counters. Counter (my variable value) , Counter 2 ( This is my 100% value  its stable) , Counter 3 ( result in percentage ).

I used -> Set Counter to :

( value( "Counter" ) + 0.0 ) / ( value( "Counter 2" ) + 0.0 ) * 100

It works. But result is value with decimals. Is it possible to set Counter 3 without decimalas (only full figures) ?
• 5th May 2018, 07:59 PM
1Ombra1
You can use the Floor function to rount it down
• 5th May 2018, 08:17 PM
moonyjacob
Wrap the entire expression with floor(value) :)
• 5th May 2018, 09:04 PM
MagnetoX
Thank you. It works.
• 7th May 2018, 12:25 AM
droberson
Do any of your counters ever go negative? Floor(value) could give you a problem.
Floor(-3.5) = -4 (moves away from zero)
Int(-3.5) = -3 (moves toward zero)

Does counter 2 ever go to 0 or 0.0? Could give you a divide-by-zero error
• 14th July 2019, 07:06 PM
RichC
Thank you - very helpful.
Hi - Thank you for posting. I was having a lot of difficulty showing a percentage with decimals in an Android game. I was didiving to counter values and could not get a proper calculation. It used to work flawlessly in Clickn' Create and in Multimedia Fusion 2.0. I think they changed something in the counter code and messed up the handling of decimals. Anyway, this solves my problem. Thank you again.
• 14th July 2019, 11:12 PM
Volnaiskra
If you need -3.5 to be -3 and 3.5 to be 3 then use int(). If you want - 3.5 to be -4 and 3.5 to be 4 then use round(). Floor() will give you - 4 and 3, as mentioned above.

And don't worry about dividing by zero. Fusion doesn't give errors for that. If an equation divides by zero, fusion just returns 0.