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 | b67852e22d66277d1ccac1aac2c284dc6fac11e5 (patch) | |
tree | e56ae5f963714c888c288531a228684a45d212be /ext/bigdecimal | |
parent | 12fd558cf3e625cd7077e24cf6b4ea9c839ea9de (diff) | |
download | ruby-b67852e22d66277d1ccac1aac2c284dc6fac11e5.tar.gz ruby-b67852e22d66277d1ccac1aac2c284dc6fac11e5.tar.xz ruby-b67852e22d66277d1ccac1aac2c284dc6fac11e5.zip |
Bug in to_digits fixed.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/bigdecimal')
-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 de5dae854..7a4a1e5e2 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 |