Percentage display without decimal places

im realy struggling to figure out how i can lose the decimal places on the read out of the percentage on my lcd desplay.
maths was never my greatest thing.
any help would be appreciate

Rpmvalue = (servoPosition);
const int min = 0, max = 170;
const float span = max - min, hundred = 100 ;
RVpercentage = hundred * (RVvalue - min) / span ;

lcd.setCursor(2,1);
lcd.print(RVpercentage);
lcd.print("%");

Welcome to the forum

Can we assume that when you print RVpercentage you are seeing 2 decimal places and that you don't to see them ?

If so, why not declare RVpercentage as an integer ?

lcd.print(RVpercentage, 0);

?

Please remember to use code tags when posting ALL of your code.

that only went and bloody done it.
iv only been at this for 2 weeks and im loving it. but got so much to learn thanks Guys.

Your codes are not compiled. Fix it first!! For test purposes I have replaced the lcd commands to Serial commands.

void setup()
{

  Serial.begin(9600);
  Rpmvalue = (servoPosition);
  const int min = 0, max = 170;
  const float span = max - min, hundred = 100 ;
  RVpercentage = hundred * (RVvalue - min) / span ;

  //Serial.setCursor(2, 1);
  Serial.print(RVpercentage);
  Serial.print("%");
}

void loop() {}

Expected Output with float RVvalue = 157.0

92%

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.