From 3c6bf0a7a354fcda3cac09e395f1fced9e2d96df Mon Sep 17 00:00:00 2001 From: Maximilian Gerhardt Date: Tue, 6 May 2025 04:34:09 +0200 Subject: [PATCH] Print number as 0 '0' instead of empty string (#189) Fixes https://github.com/openwch/arduino_core_ch32/issues/185 --- cores/arduino/Print.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 24ec039..41a3443 100644 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -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;