Skip to content
Permalink
Browse files

Add a special check for negative zero

  • Loading branch information...
skeeto committed Jul 11, 2018
1 parent 97ada39 commit 259dbafdedb95efbfc50ec9ec380b42143e2faf0
Showing with 8 additions and 1 deletion.
  1. +8 −1 bini.c
9 bini.c
@@ -374,6 +374,13 @@ parse_value(struct parser *p, struct strings *strings, int *nextc)
*nextc = get(p);
beg = escape_string(beg, end);

/* Negative zero? */
if (end - beg == 2 && beg[0] == '-' && beg[1] == '0') {
value->value.f = -0.0f;
value->type = VALUE_FLOAT;
return value;
}

/* Is it an integer? */
errno = 0;
i = strtol(beg, &end, 10);
@@ -386,7 +393,7 @@ parse_value(struct parser *p, struct strings *strings, int *nextc)
/* Is it a float? */
errno = 0;
f = (float)strtod(beg, &end);
if (!*end && (i || !errno)) {
if (!*end && (f || !errno)) {
value->value.f = f;
value->type = VALUE_FLOAT;
return value;

0 comments on commit 259dbaf

Please sign in to comment.
You can’t perform that action at this time.