Skip to content

Commit ca36657

Browse files
authored
Merge pull request #313 from fpistm/WString
Update WString
2 parents 740d316 + acbeffb commit ca36657

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Diff for: cores/arduino/WString.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ long String::toInt(void) const
742742

743743
float String::toFloat(void) const
744744
{
745-
if (buffer) return float(atof(buffer));
745+
return float(toDouble());
746+
}
747+
748+
double String::toDouble(void) const
749+
{
750+
if (buffer) return atof(buffer);
746751
return 0;
747752
}

Diff for: cores/arduino/WString.h

+5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ class String
161161
void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
162162
{getBytes((unsigned char *)buf, bufsize, index);}
163163
const char * c_str() const { return buffer; }
164+
char* begin() { return buffer; }
165+
char* end() { return buffer + length(); }
166+
const char* begin() const { return c_str(); }
167+
const char* end() const { return c_str() + length(); }
164168

165169
// search
166170
int indexOf( char ch ) const;
@@ -186,6 +190,7 @@ class String
186190
// parsing/conversion
187191
long toInt(void) const;
188192
float toFloat(void) const;
193+
double toDouble(void) const;
189194

190195
protected:
191196
char *buffer; // the actual char array

0 commit comments

Comments
 (0)