Skip to content
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

implement forceFloat32 to encode numbers in float32 instead of float64 #79

Merged
merged 3 commits into from
Jul 19, 2019

Conversation

gfx
Copy link
Member

@gfx gfx commented Jul 17, 2019

If the double precision is not required, float32 is more compact than float64.

It is useful if the precisions of numbers do not matter.

@codecov-io
Copy link

codecov-io commented Jul 17, 2019

Codecov Report

Merging #79 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #79      +/-   ##
==========================================
+ Coverage   98.15%   98.16%   +0.01%     
==========================================
  Files          15       15              
  Lines         919      927       +8     
  Branches      187      189       +2     
==========================================
+ Hits          902      910       +8     
  Misses         17       17
Impacted Files Coverage Δ
src/Encoder.ts 97.9% <100%> (+0.07%) ⬆️
src/encode.ts 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c4a1ef5...91eeb98. Read the comment docs.

@michaelficarra
Copy link

This is more of "force" than "prefer". Why not just test whether the value can be losslessly represented as a float32 and use that, otherwise use float64?

@gfx
Copy link
Member Author

gfx commented Jul 18, 2019

@michaelficarra Thanks for your advice. s/prefer/force/ at 91eeb98.

Why not just test whether the value can be losslessly represented as a float32 and use that, otherwise use float64?

I think it should make encoding much slower than the forceFloat32 option because the floating point number is a complex data type that requires much more bit operations.

@gfx gfx changed the title implement preferFloat32 to encode numbers in float32 instead of float64 implement forceFloat32 to encode numbers in float32 instead of float64 Jul 18, 2019
@gfx gfx merged commit 042337a into master Jul 19, 2019
@gfx gfx deleted the prefer-float32 branch July 19, 2019 00:04
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