Skip to content

Commit

Permalink
Revert "Fix some issues with printing float and double"
Browse files Browse the repository at this point in the history
This reverts commit b8ea343.
  • Loading branch information
bigdinotech committed May 31, 2016
1 parent 409e4b0 commit acc4b38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
21 changes: 4 additions & 17 deletions cores/arduino/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,23 +286,10 @@ size_t Print::printLongLong(unsigned long long n, uint8_t base) {
}


size_t Print::printFloat(double number, uint16_t decimalPlaces)
size_t Print::printFloat(double number, uint8_t digits)
{
if(decimalPlaces>16)
decimalPlaces = 16;
int digits = 0;
int intValue = (int)number;
while(intValue !=0)
{
intValue /= 10;
digits++;
}
digits += decimalPlaces;
if(number < 0)
digits++;
char str[digits];


dtostrf(number, 0, digits-1, str);
char str[50];

dtostrf(number, 0, digits, str);
return(print(str));
}
6 changes: 3 additions & 3 deletions cores/arduino/Print.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Print
int write_error;
size_t printNumber(unsigned long, uint8_t);
size_t printLongLong(unsigned long long, uint8_t);
size_t printFloat(double, uint16_t);
size_t printFloat(double, uint8_t);
protected:
void setWriteError(int err = 1) { write_error = err; }
public:
Expand Down Expand Up @@ -67,7 +67,7 @@ class Print
size_t print(long long, int = DEC);
size_t print(unsigned long, int = DEC);
size_t print(unsigned long long, int = DEC);
size_t print(double, int = 2);
size_t print(double, int = BIN);
size_t print(const Printable&);

size_t println(const __FlashStringHelper *);
Expand All @@ -81,7 +81,7 @@ class Print
size_t println(long long, int = DEC);
size_t println(unsigned long, int = DEC);
size_t println(unsigned long long, int = DEC);
size_t println(double, int = 2);
size_t println(double, int = BIN);
size_t println(const Printable&);
size_t println(void);
};
Expand Down

0 comments on commit acc4b38

Please sign in to comment.