-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
⚡ Faster decomposeFloat/Double
#4059
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1c798e1:
|
Looks awesome. I'll spend some time checking the diff but I think we can go with a similar optim for doubles |
Thanks! I'm happy to work on the double variant also. It looks like I broke something. How do you get unit tests to run locally? If I run |
const buffer = new ArrayBuffer(4); | ||
const view = new DataView(buffer); |
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.
Perfect! It even works with node 8 which is the currently minimal supported version for fast-check (will be dropped soon, but so far v3 is supposed to support it).
You may try: yarn # install all deps
yarn build:all # build all packages
# usually I changedir into /packages/fast-check
# but workspace commands also work
yarn test
yarn e2e # runs against prod bundle so need `yarn build` to be called before if you change things You'll also need to declare the version bump (minor for fast-check and none for others): yarn version:bump I'd need to update my contributing guide with this setup |
c2516bf
to
ffcd568
Compare
The returned `significand` and `exponent` can never be NaN, and `significand * 0x800000` will always be an integer. That means we can simplify `floatToIndex`.
ffcd568
to
f715047
Compare
Thanks for the guidance there. Fixed the failing test, switched from |
Codecov Report
@@ Coverage Diff @@
## main #4059 +/- ##
==========================================
+ Coverage 94.60% 94.64% +0.03%
==========================================
Files 211 211
Lines 5893 5897 +4
Branches 1351 1353 +2
==========================================
+ Hits 5575 5581 +6
+ Misses 302 300 -2
Partials 16 16
Flags with carried forward coverage won't be shown. Click here to find out more.
|
It seems that format is invalid. Can you please run |
f715047
to
1c798e1
Compare
decomposeFloat
implementationdecomposeFloat
implementation
Thank you so much for this awesome contribution 🥰 |
decomposeFloat
implementationdecomposeFloat/Double
My pleasure, thanks for the fast review. |
This replaces the (creative) loop-based implementation with a constant-time one. The number 1.234 is about 1100x faster and 1e30 is about 2300x faster.
If you're okay with this change I can do the same thing for double.
Category:
Potential impacts: