From 0a4b5813c368447338f27a32755212a80b290485 Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 27 Jan 2022 11:11:08 -0600 Subject: [PATCH] Update bigdecimal files from 3.1 These will eventually be sourced from the gem. https://github.com/ruby/bigdecimal/issues/169 --- lib/ruby/stdlib/bigdecimal/ludcmp.rb | 8 ++++---- lib/ruby/stdlib/bigdecimal/math.rb | 1 - lib/ruby/stdlib/bigdecimal/util.rb | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/ruby/stdlib/bigdecimal/ludcmp.rb b/lib/ruby/stdlib/bigdecimal/ludcmp.rb index 1cab9a22d00..dd265e482a3 100644 --- a/lib/ruby/stdlib/bigdecimal/ludcmp.rb +++ b/lib/ruby/stdlib/bigdecimal/ludcmp.rb @@ -76,13 +76,13 @@ def lusolve(a,b,ps,zero=0.0) end x <<= b[ps[i]] - dot end - (n-1).downto(0) do |i2| + (n-1).downto(0) do |i| dot = zero - psin = ps[i2]*n - for j in (i2+1)...n do + psin = ps[i]*n + for j in (i+1)...n do dot = a[psin+j].mult(x[j],prec) + dot end - x[i2] = (x[i2]-dot).div(a[psin+i2],prec) + x[i] = (x[i]-dot).div(a[psin+i],prec) end x end diff --git a/lib/ruby/stdlib/bigdecimal/math.rb b/lib/ruby/stdlib/bigdecimal/math.rb index b111d0acad7..5a7cd5e984f 100644 --- a/lib/ruby/stdlib/bigdecimal/math.rb +++ b/lib/ruby/stdlib/bigdecimal/math.rb @@ -1,6 +1,5 @@ # frozen_string_literal: false require 'bigdecimal' -require 'bigdecimal/util' # #-- diff --git a/lib/ruby/stdlib/bigdecimal/util.rb b/lib/ruby/stdlib/bigdecimal/util.rb index 00a3e967bd5..cb645d2a712 100644 --- a/lib/ruby/stdlib/bigdecimal/util.rb +++ b/lib/ruby/stdlib/bigdecimal/util.rb @@ -43,7 +43,7 @@ class Float < Numeric # # See also BigDecimal::new. # - def to_d(precision=Float::DIG+1) + def to_d(precision=0) BigDecimal(self, precision) end end