diff --git a/src/compiler.c b/src/compiler.c index a9d9122..214d799 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -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 diff --git a/src/obj_str.c b/src/obj_str.c index dea758d..fabac0a 100644 --- a/src/obj_str.c +++ b/src/obj_str.c @@ -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