Go Down

Topic: DS18B20 - Round Temperature (Read 1 time) previous topic - next topic

robtillaart

round the number e.g. by moving to integer domain.

pseudo code
Code: [Select]
float temp =12.34
int t = temp * 10 + 0.5;  // t = 123   (.9)  t is temp in tenths
print t/10;  // integer part
print .
print t%10;  //decimal part
print 0;


(if temp < 0 code might differ slightly)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

PaulS

From LiquidCrystal.h:
Code: [Select]
class LiquidCrystal : public Print {
So, LCD.print(someFloat, 1);
will show someFloat on the LCD rounded to one decimal place.

robtillaart

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

gnusso

Thanks Guys for the suggest,
I will try and then I'll let you know ...

Have nice week end,
Gnux

gnusso

Yes It's working with the round suggest by Paul !

Thanks you again,
Regards,
Gnux

Go Up