mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-18 07:52:14 +01:00
printInteger() & co now take longs instead of ints.
This commit is contained in:
parent
ea34315bc2
commit
c8711cd2fd
@ -218,10 +218,10 @@ void printString(char *s)
|
||||
printByte(*s++);
|
||||
}
|
||||
|
||||
void printIntegerInBase(unsigned int n, int base)
|
||||
void printIntegerInBase(unsigned long n, unsigned long base)
|
||||
{
|
||||
unsigned char buf[8 * sizeof(int)]; // Assumes 8-bit chars.
|
||||
int i = 0;
|
||||
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
||||
unsigned long i = 0;
|
||||
|
||||
if (n == 0) {
|
||||
printByte('0');
|
||||
@ -233,11 +233,11 @@ void printIntegerInBase(unsigned int n, int base)
|
||||
n /= base;
|
||||
}
|
||||
|
||||
for (i--; i >= 0; i--)
|
||||
printByte(buf[i] < 10 ? '0' + buf[i] : 'A' + buf[i] - 10);
|
||||
for (; i > 0; i--)
|
||||
printByte(buf[i - 1] < 10 ? '0' + buf[i - 1] : 'A' + buf[i - 1] - 10);
|
||||
}
|
||||
|
||||
void printInteger(int n)
|
||||
void printInteger(long n)
|
||||
{
|
||||
if (n < 0) {
|
||||
printByte('-');
|
||||
@ -247,17 +247,17 @@ void printInteger(int n)
|
||||
printIntegerInBase(n, 10);
|
||||
}
|
||||
|
||||
void printHex(unsigned int n)
|
||||
void printHex(unsigned long n)
|
||||
{
|
||||
printIntegerInBase(n, 16);
|
||||
}
|
||||
|
||||
void printOctal(unsigned int n)
|
||||
void printOctal(unsigned long n)
|
||||
{
|
||||
printIntegerInBase(n, 8);
|
||||
}
|
||||
|
||||
void printBinary(unsigned int n)
|
||||
void printBinary(unsigned long n)
|
||||
{
|
||||
printIntegerInBase(n, 2);
|
||||
}
|
||||
|
@ -73,10 +73,10 @@ void printMode(int);
|
||||
void printByte(unsigned char c);
|
||||
void printNewline();
|
||||
void printString(char *s);
|
||||
void printInteger(int n);
|
||||
void printHex(unsigned int n);
|
||||
void printOctal(unsigned int n);
|
||||
void printBinary(unsigned int n);
|
||||
void printInteger(long n);
|
||||
void printHex(unsigned long n);
|
||||
void printOctal(unsigned long n);
|
||||
void printBinary(unsigned long n);
|
||||
|
||||
unsigned long millis(void);
|
||||
void delay(unsigned long);
|
||||
|
Loading…
x
Reference in New Issue
Block a user