Hi,
I'm trying to print a couple of floats (some with, some without decimal digits) right aligned on an OLED. To do that I use .length() to find out where to put the cursor. For most numbers, my code works. for positive, single digit numbers, the result is weird:
float pi = 3.1415;
u8g2.print(String(pi, 2)); // gives "3.14" - as expected
u8g2.print(String(pi, 2).length()); // gives "4" - as expected
u8g2.print(String(pi, 0)); // gives " 3" - note the leading blank
u8g2.print(String(pi, 0).length()); // gives "2" as opposed to the expected "1" due to the leading blank
[hr]
Any idea why that is happening? - Or how to do it better?
Many thanks,
Frank