Skip to content

Improve consistency of JS_NewFloat64 API#319

Merged
chqrlie merged 7 commits intoquickjs-ng:masterfrom
chqrlie:fix-js-float64
Mar 25, 2024
Merged

Improve consistency of JS_NewFloat64 API#319
chqrlie merged 7 commits intoquickjs-ng:masterfrom
chqrlie:fix-js-float64

Conversation

@chqrlie
Copy link
Copy Markdown
Collaborator

@chqrlie chqrlie commented Mar 16, 2024

  • 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

chqrlie added 2 commits March 16, 2024 09:24
- `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`
Comment thread quickjs.c
@chqrlie
Copy link
Copy Markdown
Collaborator Author

chqrlie commented Mar 17, 2024

@bnoordhuis do you approve this PR? I would like to move ahead with other features and commit to bellard/quickjs too.

Comment thread quickjs.c Outdated
Comment thread quickjs.c
} else {
// fractional if low bits are non-zero
return !(u << 12 << e);
}
Copy link
Copy Markdown
Contributor

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.

Comment thread quickjs.c Outdated
Comment thread quickjs.c Outdated
@chqrlie chqrlie merged commit 3b50de4 into quickjs-ng:master Mar 25, 2024
@chqrlie chqrlie deleted the fix-js-float64 branch March 26, 2024 12:24
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()
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants