Skip to content

Port bellard/quickjs sumPrecise#1170

Merged
bnoordhuis merged 6 commits intoquickjs-ng:masterfrom
bptato:sumprecise
Sep 29, 2025
Merged

Port bellard/quickjs sumPrecise#1170
bnoordhuis merged 6 commits intoquickjs-ng:masterfrom
bptato:sumprecise

Conversation

@bptato
Copy link
Copy Markdown
Contributor

@bptato bptato commented Sep 28, 2025

It's more compact than xsum.

Copy link
Copy Markdown
Contributor

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

a = float64_as_uint64(d);
sgn = a >> 63;
e = (a >> 52) & ((1 << 11) - 1);
m = a & (((uint64_t)1 << 52) - 1);
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.

Maybe a little more legible as:

Suggested change
m = a & (((uint64_t)1 << 52) - 1);
m = a & ((1ULL << 52) - 1);

Although I can't fault you for being precise with types. Consider it just a suggestion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the rest of the code uses the uint64_t pattern too, so I think it's better to stick to it.

Copy link
Copy Markdown
Contributor

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@bnoordhuis bnoordhuis merged commit a13b04f into quickjs-ng:master Sep 29, 2025
127 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants