BigMath methods returns inaccurate value for rational
还没有人认领这个 Issue。
评估
调研方向
从 BigMath.exp、log、sqrt、sin 和 cos 入口开始,重点关注它们从 Rational 到 BigDecimal 的转换。比较 issue 中 precision-50 和 precision-1000 的示例,以了解所展示的精度损失。当报告的 Rational 案例能够保留所请求的精度,且不存在所展示的差异时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Because Rational is simply converted to BigDecimal with the given precision. Precision is not that simple.
Though it may not be a responsibility for BigMath.
BigMath.exp: Maximum 19 digits precision loss
BigMath.exp(10**19/3r, 50).to_s[0,52]
#=> "0.31897971307307432918427098497346266668405585204999"
BigMath.exp(10**19/3r, 1000).to_s[0,52]
#=> "0.31897971307307432918427098497347329934115828786096"
BigMath.log: Many precision loss near x=1
BigMath.log(1+1r/12345**9, 50)
#=> 0.15016895257719999999999999999999999998872464284093e-36
BigMath.log(1+1r/12345**9, 1000).mult(1, 50)
#=> 0.1501689525772244244950394251097065861542145195459e-36
BigMath.sin: Many precision loss near x=n*π
x = (31415926535897932384626433832795 * 7 + 1).quo(7 * 10**40)
BigMath.sin(x, 50)
#=> 0.26542232205820974944592307816406286208998628034825e-40
BigMath.sin(x, 1000).mult(1, 50)
#=> 0.26542232248678117801735164959263429066141485177682e-40
Each method requires different Rational to BigDecimal conversion. For example:
- log:
x < 1/2r ? BigDecimal(x, prec) : BigDecimal(x - 1, prec) + 1 - exp:
BigDecimal(x, prec + [BigDecimal(x, 1).exponent, 0].max) - sqrt: Nothing special.
BigDecimal(x, prec) - sin, cos: Needs precision increasing loop
- 主要语言
- C
- 星标
- 152
- 派生
- 99
- 平均合并
- 6 小时 44 分钟
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/bigdecimal 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
ruby/bigdecimal#569 ·
-
难度 5/5 一周以上 新手友好度 35/100
ruby/bigdecimal#566 ·
-
难度 4/5 3-5 天 新手友好度 45/100
ruby/bigdecimal#506 · 4 条评论 ·
-
难度 5/5 一周以上 新手友好度 30/100
ruby/bigdecimal#491 ·
-
难度 3/5 1-2 天 新手友好度 35/100
ruby/bigdecimal#291 · 6 条评论 ·
相似的 Issue
-
bug core p3
难度 2/5 1-3 小时 新手友好度 72/100
RunanywhereAI/runanywhere-sdks#1258 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
rolotrealanis98/open-apollo#126 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 85/100
onehumanbeing/esp32-iphone-agent#62 ·
维护者通常 1 天内回复
-
ai-driven-fuzzing bug claude Minor
难度 2/5 1-3 小时 新手友好度 78/100
linagora/open-bastion#425 ·
维护者通常 1 天内回复