Skip to content

exmath.Round 精度为负数时结果精准度问题 #14#15

Merged
thinkeridea merged 1 commit intomainfrom
exmath.Round
Jan 12, 2021
Merged

exmath.Round 精度为负数时结果精准度问题 #14#15
thinkeridea merged 1 commit intomainfrom
exmath.Round

Conversation

@thinkeridea
Copy link
Copy Markdown
Owner

该提交用于修复 #14 精度问题,其原因为 precision < 0 其参与计算的浮点数比较小,导致最终运算结果精度得不到保证

分别处理 precision = 0precision <0 precision > 0 的情况,以保证精准度为核心目标。

新实现相较于旧方案性能略有下降:

name            old time/op  new time/op  delta
Round-8         3.45ns ± 1%  4.04ns ±14%  +17.25%  (p=0.000 n=44+46)
RoundDecimal-8  3.47ns ± 1%  3.86ns ± 2%  +11.17%  (p=0.000 n=40+50)
RoundInteger-8  4.38ns ± 1%  5.14ns ± 1%  +17.38%  (p=0.000 n=49+48)

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 12, 2021

Codecov Report

Merging #15 (7f71041) into main (70de57e) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #15      +/-   ##
==========================================
+ Coverage   90.72%   90.77%   +0.04%     
==========================================
  Files          25       25              
  Lines         787      791       +4     
==========================================
+ Hits          714      718       +4     
  Misses         51       51              
  Partials       22       22              
Impacted Files Coverage Δ
exmath/round.go 100.00% <100.00%> (ø)

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 70de57e...7f71041. Read the comment docs.

@thinkeridea thinkeridea merged commit b27a4fe into main Jan 12, 2021
@thinkeridea thinkeridea deleted the exmath.Round branch January 12, 2021 15:15
@thinkeridea thinkeridea changed the title exmath.Round 精度为负数时结算精准度问题 #14 exmath.Round 精度为负数时结果精准度问题 #14 Jan 19, 2021
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.

1 participant