diff options
author | shigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-05 09:32:09 +0000 |
---|---|---|
committer | shigek <shigek@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-08-05 09:32:09 +0000 |
commit | f2c49270e75313b9438bfb80bd99925dbe9ca1b2 (patch) | |
tree | e56ae5f963714c888c288531a228684a45d212be /ext | |
parent | 70903de1cdd517cc5c4f679e33d0a6ae59d8063a (diff) | |
download | ruby-f2c49270e75313b9438bfb80bd99925dbe9ca1b2.tar.gz |
Bug in to_digits fixed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/bigdecimal/lib/bigdecimal/util.rb | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb index de5dae8546..7a4a1e5e2d 100644 --- a/ext/bigdecimal/lib/bigdecimal/util.rb +++ b/ext/bigdecimal/lib/bigdecimal/util.rb @@ -33,17 +33,14 @@ end class BigDecimal < Numeric # to "nnnnnn.mmm" form digit string def to_digits - if self.nan? || self.infinite? + if self.nan? || self.infinite? || self.zero? self.to_s else - s,i,y,z = self.fix.split + i = self.to_i.to_s s,f,y,z = self.frac.split - if s > 0 - s = "" - else - s = "-" - end - s + i + "." + f + f = f.gsub(/0+$/,"") + f = "0" if f=="" + i + "." + ("0"*(-z)) + f end end |