Improve consistency of JS_NewFloat64 API#319
Merged
chqrlie merged 7 commits intoquickjs-ng:masterfrom Mar 25, 2024
Merged
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`
saghul
reviewed
Mar 16, 2024
saghul
approved these changes
Mar 16, 2024
Collaborator
Author
|
@bnoordhuis do you approve this PR? I would like to move ahead with other features and commit to bellard/quickjs too. |
bnoordhuis
reviewed
Mar 18, 2024
bnoordhuis
approved these changes
Mar 22, 2024
| } else { | ||
| // fractional if low bits are non-zero | ||
| return !(u << 12 << e); | ||
| } |
Contributor
There was a problem hiding this comment.
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
past-due
added a commit
to past-due/quickjs-ng
that referenced
this pull request
Sep 18, 2025
Re-apply quickjs-ng#319, use of js_number()
past-due
added a commit
to past-due/quickjs-ng
that referenced
this pull request
Sep 18, 2025
Re-apply quickjs-ng#319, use of js_number()
3 tasks
past-due
added a commit
to past-due/quickjs-ng
that referenced
this pull request
Sep 25, 2025
Re-apply quickjs-ng#319, use of js_number()
cuiweixie
pushed a commit
to cuiweixie/quickjs
that referenced
this pull request
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JS_NewFloat64()always creates aJS_TAG_FLOAT64value__JS_NewFloat64asJS_NewFloat64__to avoid reserved name issuejs_float64()always creates aJS_TAG_FLOAT64valuejs_int64internal function for consistencyfloat_is_int32and rename asdouble_is_int32INT32_MINindouble_is_int32js_number(d)to create aJS_TAG_FLOAT64or aJS_TAG_INTvalue if possibleJS_NewNumber()API for the same purposejs_atof2JS_NewBigInt64_1intoJS_NewBigInt64