Print number as 0 '0' instead of empty string (#189)

Fixes https://github.com/openwch/arduino_core_ch32/issues/185
This commit is contained in:
Maximilian Gerhardt 2025-05-06 04:34:09 +02:00 committed by GitHub
parent 7e416ab108
commit 3c6bf0a7a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -356,6 +356,12 @@ size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
uint8_t i = 0;
uint8_t innerLoops = 0;
// Special case workaround https://github.com/arduino/ArduinoCore-API/issues/178
if (n64 == 0) {
write('0');
return 1;
}
// prevent crash if called with base == 1
if (base < 2) {
base = 10;