reduce length of a float number

Hello everyone!
I am trying to print the temperature of a DS18B20 into an LCD screen! However, the thermometer gives a float value of 2 decimal figures e.g. 28.50. At this point I have reduced the presition of DS18B20 so the accurase is 0.5. In result, I don’t need the last digit which is always a 0 but I cannot get read of it! Any ideas?

I’ve even tried to use some function that I made as seen in the attachments, but I got no luck! Any ideas?

I know that I can simply erase the last digit from my screen but I don’t want that kind of a solution!

div.jpg

div2.jpg

Pictures of code aren’t very helpful. Copy and paste the code here. Be sure to put it between code tags so the forum software doesn’t mangle it.

You can always set the precision of a float when using print. The second argument tells how many digits after the decimal. For one digit:

lcd.print(someFloat , 1);

I must be missing something here:

void setup() {
  char buff[10];
  float val = 12.345;

  dtostrf(val,7, 1, buff);      // This right-justifies in a field of 7
  
  Serial.begin(9600);
  Serial.println(buff);
  Serial.println(val, 1);       // Standard
}

void loop() {

}

Delta_G: Pictures of code aren't very helpful. Copy and paste the code here. Be sure to put it between code tags so the forum software doesn't mangle it.

You can always set the precision of a float when using print. The second argument tells how many digits after the decimal. For one digit:

lcd.print(someFloat , 1);

Sorry about the images, I am pretty new to this forum so I am not familiar with it yet! Also, thank you for the instructions!!

Your solution works out of the box! I didn't know that something like this was posible!!

Achileas7: I didn't know that something like this was posible!!

At the top of this page is a blue-green bar with different links. One of them is Learning. Go there and look around. There's lots you don't know and there's lots of questions you don't even know you need to ask yet. But if you'll just explore around there a little bit, when those questions come up you'll have a pretty good grasp on where to go to find answers.

https://www.arduino.cc/en/Serial/Print