mirror of https://github.com/noisymime/Arduino.git
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++);
|
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.
|
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
||||||
int i = 0;
|
unsigned long i = 0;
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
printByte('0');
|
printByte('0');
|
||||||
|
@ -233,11 +233,11 @@ void printIntegerInBase(unsigned int n, int base)
|
||||||
n /= base;
|
n /= base;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i--; i >= 0; i--)
|
for (; i > 0; i--)
|
||||||
printByte(buf[i] < 10 ? '0' + buf[i] : 'A' + buf[i] - 10);
|
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) {
|
if (n < 0) {
|
||||||
printByte('-');
|
printByte('-');
|
||||||
|
@ -247,17 +247,17 @@ void printInteger(int n)
|
||||||
printIntegerInBase(n, 10);
|
printIntegerInBase(n, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printHex(unsigned int n)
|
void printHex(unsigned long n)
|
||||||
{
|
{
|
||||||
printIntegerInBase(n, 16);
|
printIntegerInBase(n, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printOctal(unsigned int n)
|
void printOctal(unsigned long n)
|
||||||
{
|
{
|
||||||
printIntegerInBase(n, 8);
|
printIntegerInBase(n, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printBinary(unsigned int n)
|
void printBinary(unsigned long n)
|
||||||
{
|
{
|
||||||
printIntegerInBase(n, 2);
|
printIntegerInBase(n, 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,10 +73,10 @@ void printMode(int);
|
||||||
void printByte(unsigned char c);
|
void printByte(unsigned char c);
|
||||||
void printNewline();
|
void printNewline();
|
||||||
void printString(char *s);
|
void printString(char *s);
|
||||||
void printInteger(int n);
|
void printInteger(long n);
|
||||||
void printHex(unsigned int n);
|
void printHex(unsigned long n);
|
||||||
void printOctal(unsigned int n);
|
void printOctal(unsigned long n);
|
||||||
void printBinary(unsigned int n);
|
void printBinary(unsigned long n);
|
||||||
|
|
||||||
unsigned long millis(void);
|
unsigned long millis(void);
|
||||||
void delay(unsigned long);
|
void delay(unsigned long);
|
||||||
|
|
Loading…
Reference in New Issue