Skip to content

Commit

Permalink
Use new float parser instead of strtod
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Feb 28, 2024
1 parent ce6ddec commit 34a6e30
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,7 @@ static void number(struct GlobalState * state, int exprType, RewindState *rewind
for (size_t j = 0; j < state->parser.previous.length; ++j) {
if (state->parser.previous.start[j] == '.') {
#ifndef KRK_NO_FLOAT
double value = strtod(start, NULL);
emitConstant(FLOATING_VAL(value));
emitConstant(krk_parse_float(start, state->parser.previous.length));
#else
error("no float support");
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/obj_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ KRK_Method(str,__int__) {
KRK_Method(str,__float__) {
METHOD_TAKES_NONE();
#ifndef KRK_NO_FLOAT
return FLOATING_VAL(strtod(AS_CSTRING(argv[0]),NULL));
return krk_parse_float(AS_CSTRING(argv[0]),AS_STRING(argv[0])->length);
#else
return krk_runtimeError(vm.exceptions->valueError, "no float support");
#endif
Expand Down

0 comments on commit 34a6e30

Please sign in to comment.