You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some more testing I found that the problem is actually with ultoa(), and also ltoa(). The String(unsigned long) constructor uses ultoa() for the conversion, while String(long) uses sprintf("%ld") when base is 10 (which works as expected), and ltoa() for other cases, which fail.
So, both ltoa() and ultoa() reverse digits.
unsigned long value = 123456789;
char buf[10];
ultoa(value, buf, 10);
Serial.print(buf);
produces "987654321"
The text was updated successfully, but these errors were encountered:
Arduino 1.8.15
ESP32 v2.0.0-rc-1
ESP32-S2-WROVER (Saola 1)
String() constructor from unsigned long reverses digits.
Code:
Output:
After some more testing I found that the problem is actually with ultoa(), and also ltoa(). The String(unsigned long) constructor uses ultoa() for the conversion, while String(long) uses sprintf("%ld") when base is 10 (which works as expected), and ltoa() for other cases, which fail.
So, both ltoa() and ultoa() reverse digits.
produces "987654321"
The text was updated successfully, but these errors were encountered: