Skip to content

Commit

Permalink
fixed atof implementation, atof ignored the initial sign
Browse files Browse the repository at this point in the history
  • Loading branch information
peterzuger committed Dec 1, 2020
1 parent 1c0dc92 commit f396c3a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tlc5947/tlc5947.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,12 @@ float atof(const char *s){
float a = 0.0;
int e = 0;
int c;
bool sign = false;

if (*s == '-'){
s++;
sign = true;
}

while ((c = *s++) != '\0' && isdigit(c)) {
a = a * 10.0f + (c - '0');
Expand Down Expand Up @@ -780,7 +786,7 @@ float atof(const char *s){
a *= 0.1f;
e++;
}
return a;
return sign ? -a : a;
}

static void tokenize_pattern_str(const char* s, token_t* pat, size_t len){
Expand Down

0 comments on commit f396c3a

Please sign in to comment.