mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-30 19:52:13 +01:00
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.
This commit is contained in:
parent
dd73973d8d
commit
9509587472
@ -257,7 +257,7 @@ size_t Print::printFloat(double number, uint8_t digits)
|
|||||||
while (digits-- > 0)
|
while (digits-- > 0)
|
||||||
{
|
{
|
||||||
remainder *= 10.0;
|
remainder *= 10.0;
|
||||||
int toPrint = int(remainder);
|
unsigned toPrint = unsigned(remainder);
|
||||||
n += print(toPrint);
|
n += print(toPrint);
|
||||||
remainder -= toPrint;
|
remainder -= toPrint;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user