Actions
Bug #19713
closedOff-by-one error when computing very large Integer numbers
Description
Ruby computes this Elliptic Curve result incorrectly when using Integer operations, but has the correct result when using Rational:
a = 154476802108746166441951315019919837485664325669565431700026634898253202035277999
b = 36875131794129999827197811565225474825492979968971970996283137471637224634055579
c = 4373612677928697257861252602371390152816537558161613618621437993378423467772036
int = a / (b + c) + b / (a + c) + c / (a + b)
a = a.to_r
rational = a / (b + c) + b / (a + c) + c / (a + b)
puts [RUBY_VERSION, int == 4, rational == 4].join(' ')
Unfortunately, I'm not sure how to minimize this to something simpler than an EC computation.
Actual¶
➜ ~ asdf local ruby latest && ruby foo.rb
3.2.1 false true
➜ ~ asdf local ruby 3.1.3 && ruby foo.rb
3.1.3 false true
➜ ~
Expected¶
➜ ~ asdf local ruby latest && ruby foo.rb
3.2.1 true true
➜ ~ asdf local ruby 3.1.3 && ruby foo.rb
3.1.3 true true
➜ ~
Actions
Like0
Like0Like0