Calculating Percent question

Hey everyone,
I was adding a servo to display fuel level (volts really) in my sons arduino two wheel robot,
I tried using this formula ' (100/22)cell,
If cell = 22 value then the answer should be 100, or full,
However the arduino gives me 88!!! every time.
It gives 0 for 0, correctly,
So to solve this I had to use ' cell
4.54 , which gives me the 0 at 0 and 100(full) at 23.

Why does the arduino do this?, I noticed in some other sample code that the programmer used the * figure also.
My calculator does it fine.
Regards, Matt.

That's probably because it uses an integer division by default. The fraction part is just cut off.

To use floating point numbers, try (100.0/22) instead.

Pieter

Or, change it to: (cell * 100) / 22

In integer math, 100 / 22 = 4, and 4 * 22 = 88.

Using the equation above, 22 * 100 = 2200, and 2200 / 22 = 100

Regards,
Ray L.

Oh crap I even read about that a while ago in the help, I forgot about integer math , Thanks for the reply guys.