Issue with decimal place

So I have code that is giving me a result when rotary encoder is turned.

#include <LCD5110_Graph.h>
#include <ClickEncoder.h>
#include <TimerOne.h>
LCD5110 lcd(8,9,10,12,11);
extern unsigned char SmallFont[];
extern unsigned char TinyFont[];

ClickEncoder *encoder;
int16_t last, value = 11968;

void timerIsr() {
encoder->service();
}


void setup() {
 
Serial.begin(9600);
lcd.InitLCD();
lcd.setFont(SmallFont);
lcd.print("Altimeter",CENTER,15);
lcd.update();
delay(2000);
lcd.setFont(SmallFont);
encoder = new ClickEncoder(A1, A0, A2);
Timer1.initialize(1000);
Timer1.attachInterrupt(timerIsr); 
 
last = -1;
}

void loop() {  
int q;
lcd.setFont(SmallFont);
char qnh[3]; 


value += encoder->getValue();
 
if (value != last) {
last = value;
q = (value/4);
 
Serial.print("QNH: ");
Serial.println(q);
lcd.clrScr();
lcd.print("QNH: ",LEFT,0);
dtostrf(q, 3, 0, qnh);
lcd.print(qnh,LEFT+45,0);
lcd.update();
}
 
 
}

Result 2992. I need 29.92

However if I change
q = (value/4); to "value/4*0.01" or "value/4/100" I get:
29 and no decimals

Hi,

Try
change int q to float q;

tauro0221:
Hi,

Try
change int q to float q;

Just did. And added *0.01. I get 29.92showing in the serial monitor. LCD still just shows 30. It's rounding up.

Try:

Serial.println(2992 / 100.0);

Hi,
Then do Serial.println(2992 *100.0);

Or:

Serial.println(q / 400.0);

Here's the modified code

void loop() {  
float q = value/4*0.01;
lcd.setFont(SmallFont);
char qnh[3]; 


value += encoder->getValue();
 
if (value != last) {
last = value;
 
 
Serial.print("QNH: ");
Serial.println(q);
lcd.clrScr();
lcd.print("QNH: ",LEFT,0);
dtostrf(q, 3, 0, qnh);
lcd.print(qnh,LEFT+25,0);
lcd.update();
}
 
 
}

Serial monitor result: QNH: 29.92
LCD result: QNH: 30

Once I turn the encoder so serial is showing "29.49" the LCD will show "29"

Got it working.

dtostrf(q, 3, 0, qnh);

Should have been
dtostrf(q, 3, 2, qnh);