From: "mame (Yusuke Endoh) via ruby-core" Date: 2023-06-06T05:11:42+00:00 Subject: [ruby-core:113774] [Ruby master Bug#19713] Off-by-one error when computing very large Integer numbers Issue #19713 has been updated by mame (Yusuke Endoh). Status changed from Open to Rejected It is by design. `Integer#/` does integer division. ``` p 2 / 1 #=> 0 ``` ---------------------------------------- Bug #19713: Off-by-one error when computing very large Integer numbers https://bugs.ruby-lang.org/issues/19713#change-103423 * Author: bannable (Joe Truba) * Status: Rejected * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- 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 ��� ~ ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/