diff options
author | Tevin Zhang <mail2tevin@gmail.com> | 2013-05-29 10:42:07 +0800 |
---|---|---|
committer | Cristian Maglie <c.maglie@bug.st> | 2013-06-06 16:19:34 +0200 |
commit | c8a79d0d0c999997d2ee9cd5b773b5ff6561e130 (patch) | |
tree | 44bc39518d36d085d8827a4fba4eb1f7908ba316 /cores/arduino/WString.h | |
parent | 6bef2ada0627be776e463661ccbcdeba5a373f3a (diff) |
add String.toFloat
Diffstat (limited to 'cores/arduino/WString.h')
-rw-r--r-- | cores/arduino/WString.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index b587a3d..2d372c5 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -68,6 +68,8 @@ public: explicit String(unsigned int, unsigned char base=10); explicit String(long, unsigned char base=10); explicit String(unsigned long, unsigned char base=10); + explicit String(float, int decimalPlaces=6); + explicit String(double, int decimalPlaces=6); ~String(void); // memory management @@ -100,6 +102,8 @@ public: unsigned char concat(unsigned int num); unsigned char concat(long num); unsigned char concat(unsigned long num); + unsigned char concat(float num); + unsigned char concat(double num); // if there's not enough memory for the concatenated value, the string // will be left unchanged (but this isn't signalled in any way) @@ -120,6 +124,8 @@ public: friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num); friend StringSumHelper & operator + (const StringSumHelper &lhs, long num); friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, float num); + friend StringSumHelper & operator + (const StringSumHelper &lhs, double num); // comparison (only works w/ Strings and "strings") operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; } @@ -172,6 +178,7 @@ public: // parsing/conversion long toInt(void) const; + float toFloat(void) const; protected: char *buffer; // the actual char array |