Adding zero padding to decimal values I want to add zero before the float number like this:
010.0

The code I'm using is this:
if(value &lt; 10){
  lcd.print(F(&quot;0&quot;));
}

lcd.print(value);

But when the value is exactly 10, it adds the zero anyway:
0010.0

I tried something like this but haven't had any luck:
if(value &lt; 10 &amp;&amp; value != 10){
  lcd.print(F(&quot;0&quot;));
}


How can I solve this issue?

- EDIT:
#include &lt;LiquidCrystal_I2C.h&gt;
LiquidCrystal_I2C lcd(0x3B, 16, 2);

#define turnOff 3
#define turnOn 2
#define gateStatus 8
#define btn 4

float ADC0, current, ADC1, voltage, ADC2, temp, watt;
int8_t state, btnState, btnPushed, btnToggle, lcdClear;
uint32_t deBounce = 0;

void setup() {
  analogReference(EXTERNAL);
  pinMode(turnOff, OUTPUT);
  pinMode(turnOn, OUTPUT);
  pinMode(gateStatus, INPUT);
  pinMode(btn, INPUT_PULLUP);
  pinMode(13, OUTPUT);
  lcd.begin();
}

void loop() {
  digitalWrite(13, LOW);
  state = digitalRead(gateStatus);
  btnState = digitalRead(btn);

  if (!btnState) {
    if (millis() - deBounce &gt; 200) {
      btnPushed = 1;
      deBounce = millis();
    }
  }
  if (btnPushed &amp;&amp; btnState) {
    btnToggle = 1;
  }
  if (btnToggle &amp;&amp; state) {
    digitalWrite(turnOn, HIGH);
    delay(5);
    digitalWrite(turnOn, LOW);
    btnToggle = 0;
    btnPushed = 0;
  }
  if (btnToggle &amp;&amp; !state) {
    digitalWrite(turnOff, HIGH);
    delay(5);
    digitalWrite(turnOff, LOW);
    btnToggle = 0;
    btnPushed = 0;
  }

  for (int i = 0; i &lt; 500; ++i) {
    ADC0 += analogRead(A0);
  }
  ADC0 /= 500;
  current = ADC0 * (2.5 / 1023.0);
  current = current / 0.211;


  for (int i = 0; i &lt; 500; ++i) {
    ADC1 += analogRead(A1);
  }
  ADC1 /= 500;
  voltage = ADC1 * (2.5 / 1023.0);
  voltage = voltage * 20.2;

  for (int i = 0; i &lt; 100; ++i) {
    ADC2 += analogRead(A2);
  }
  ADC2 /= 100;
  temp = ADC2 * (2.5 / 1023.0);
  temp = temp * 100.5;

  watt = voltage * current;

  lcd.setCursor(0, 0);
  if(voltage &lt; 10){
    lcd.print(F(&quot;0&quot;));
  }
  lcd.print(voltage);
  lcd.setCursor(5, 0);
  lcd.print(F(&quot; V&quot;));

  lcd.setCursor(9, 0);
  if(temp &lt; 10){
    lcd.print(F(&quot;0&quot;));
  }
  lcd.print(temp, 1);
  lcd.print((char)223);
  lcd.print(F(&quot; C&quot;));

  if (state) {
    lcd.setCursor(0, 1);
    lcd.print(F(&quot;   OUTPUT OFF   &quot;));
    lcdClear = 1;
  }

  else {
    if (lcdClear) {
      lcd.clear();
      lcdClear = 0;
    }
    lcd.setCursor(0, 1);
    if (current &lt; 10) {
      lcd.print(F(&quot;0&quot;));
    }
    lcd.print(current);
    lcd.setCursor(5, 1);
    lcd.print(F(&quot; A&quot;));

    lcd.setCursor(9, 1);
    if (watt &lt; 10) {
      lcd.print(F(&quot;0&quot;));
    }
    if (watt &lt; 100) {
      lcd.print(F(&quot;0&quot;));
    }
    lcd.print(watt, 1);
    lcd.setCursor(14, 1);
    lcd.print(F(&quot; W&quot;));
  }
}
This looks like a rounding problem. If the number you want to print lies
within the open interval (9.95, 10), the condition value &lt; 10 is true,
as the number is strictly less than 10. Obviously, value != 10 is also
true. Yet, lcd.print(x, 1) will round the number to the closest
multiple of 0.1, which in this case is 10.
I see no better solution than handling the rounding yourself. I would
use integers for the comparison, as they avoid all rounding issues:
// Print a float to the LCD in 2.1 format (xx.x), left padded with a
// zero if needed. Assume x &lt; 100.
void printPadded(float x)
{
    // Left pad.
    int i = round(x * 10);
    if (i &lt; 100) lcd.write('0');

    // Print the rounded value.
    lcd.print(i * 0.1, 1);
}