File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 2424
2525#include " Common.h"
2626#include " Stream.h"
27- #include < math.h>
2827
2928#define PARSE_TIMEOUT 1000 // default number of milli-seconds to wait
3029
@@ -165,7 +164,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
165164 bool isFraction = false ;
166165 double value = 0.0 ;
167166 int c;
168- unsigned int digits_post_comma = 0 ;
167+ double fraction = 1. 0 ;
169168
170169 c = peekNextDigit (lookahead, true );
171170 // ignore non numeric leading characters
@@ -182,7 +181,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
182181 else if (c >= ' 0' && c <= ' 9' ) { // is c a digit?
183182 value = value * 10 + c - ' 0' ;
184183 if (isFraction)
185- digits_post_comma++ ;
184+ fraction *= 0.1 ;
186185 }
187186 read (); // consume the character we got with peek
188187 c = timedPeek ();
@@ -193,7 +192,7 @@ float Stream::parseFloat(LookaheadMode lookahead, char ignore)
193192 value = -value;
194193
195194 if (isFraction)
196- value /= pow ( 10 , digits_post_comma) ;
195+ value *= fraction ;
197196
198197 return value;
199198}
You can’t perform that action at this time.
0 commit comments