Skip to content

Commit 9509587

Browse files
committed
Speed and size improvement in Print::printFloat()
Avoid using the overload of print() for signed integer since a negative value is not allowed here. This results in a smaller (unless print(int) is used somewhere else in the program) and faster code because the overload for unsigned integer is simpler.
1 parent dd73973 commit 9509587

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

hardware/arduino/avr/cores/arduino/Print.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ size_t Print::printFloat(double number, uint8_t digits)
257257
while (digits-- > 0)
258258
{
259259
remainder *= 10.0;
260-
int toPrint = int(remainder);
260+
unsigned toPrint = unsigned(remainder);
261261
n += print(toPrint);
262262
remainder -= toPrint;
263263
}

0 commit comments

Comments
 (0)