-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve consistency of JS_NewFloat64 API #319
Conversation
- `JS_NewFloat64()` always creates a `JS_TAG_FLOAT64` value - rename `__JS_NewFloat64` as `JS_NewFloat64__` to avoid reserved name issue - internal `js_float64()` always creates a `JS_TAG_FLOAT64` value - add `js_int64` internal function for consistency - simplify `float_is_int32` and rename as `double_is_int32` - handle `INT32_MIN` in `double_is_int32` - add `js_number(d)` to create a `JS_TAG_FLOAT64` or a `JS_TAG_INT` value if possible - add `JS_NewNumber()` API for the same purpose - use non testing constructor for infinities in `js_atof2` - always store internal time value as a float64 - merge `JS_NewBigInt64_1` into `JS_NewBigInt64`
@bnoordhuis do you approve this PR? I would like to move ahead with other features and commit to bellard/quickjs too. |
} else { | ||
// fractional if low bits are non-zero | ||
return !(u << 12 << e); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm being brutally honest, I feel the old version of this function is more legible. Machine code-wise, it's probably a wash; I don't expect this version to be particularly faster.
- use comparisons instead of `(int32_t)` casts
JS_NewFloat64()
always creates aJS_TAG_FLOAT64
value__JS_NewFloat64
asJS_NewFloat64__
to avoid reserved name issuejs_float64()
always creates aJS_TAG_FLOAT64
valuejs_int64
internal function for consistencyfloat_is_int32
and rename asdouble_is_int32
INT32_MIN
indouble_is_int32
js_number(d)
to create aJS_TAG_FLOAT64
or aJS_TAG_INT
value if possibleJS_NewNumber()
API for the same purposejs_atof2
JS_NewBigInt64_1
intoJS_NewBigInt64