Skip to content

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

Merged
gfx merged 3 commits into
masterfrom
prefer-float32
Jul 19, 2019
Merged

gfx merged 3 commits into
masterfrom
prefer-float32

Conversation

@gfx

@gfx gfx commented Jul 17, 2019 •

Copy link
Copy Markdown
Member

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

codecov-io commented Jul 17, 2019 •

Copy link
Copy Markdown

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
Copy Markdown

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

gfx commented Jul 18, 2019

Copy link
Copy Markdown
Member Author

@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