diff --git a/quickjs.c b/quickjs.c index e8fdd8a..9e9b8db 100644 --- a/quickjs.c +++ b/quickjs.c @@ -10286,7 +10286,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp, } else #endif { - double d = 1.0 / 0.0; + double d = INFINITY; if (is_neg) d = -d; val = JS_NewFloat64(ctx, d); @@ -43090,7 +43090,7 @@ static JSValue js_math_min_max(JSContext *ctx, JSValueConst this_val, uint32_t tag; if (unlikely(argc == 0)) { - return __JS_NewFloat64(ctx, is_max ? -1.0 / 0.0 : 1.0 / 0.0); + return __JS_NewFloat64(ctx, is_max ? -INFINITY : INFINITY); } tag = JS_VALUE_GET_TAG(argv[0]); @@ -49418,7 +49418,7 @@ static const JSCFunctionListEntry js_global_funcs[] = { JS_CFUNC_MAGIC_DEF("encodeURIComponent", 1, js_global_encodeURI, 1 ), JS_CFUNC_DEF("escape", 1, js_global_escape ), JS_CFUNC_DEF("unescape", 1, js_global_unescape ), - JS_PROP_DOUBLE_DEF("Infinity", 1.0 / 0.0, 0 ), + JS_PROP_DOUBLE_DEF("Infinity", INFINITY, 0 ), JS_PROP_DOUBLE_DEF("NaN", NAN, 0 ), JS_PROP_UNDEFINED_DEF("undefined", 0 ), JS_PROP_STRING_DEF("[Symbol.toStringTag]", "global", JS_PROP_CONFIGURABLE ),