Class: Float
Instance Method Summary collapse
-
#sign ⇒ Object
There seems to be no legal way to retrieve the negative sign of -0.0.
-
#split ⇒ Object
analogous to BigDecimal#split.
Methods inherited from Numeric
#make_digits, #to_decimal, #to_money, #to_percent
Instance Method Details
#sign ⇒ Object
There seems to be no legal way to retrieve the negative sign of -0.0. If you really need it, convert the number to BigDecimal.
-0.0.to_f.to_d.sign #=> -1
284 |
# File 'lib/numrepr/format.rb', line 284 def sign ; super ; end |
#split ⇒ Object
analogous to BigDecimal#split
287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/numrepr/format.rb', line 287 def split m, e = abs.to_s.split /e/i e = e.to_i d, f = m.split "." d.lstrip! "0" rescue d.slice! /\A0+/ # before Ruby 4.0 e += d.count "0-9" if f then f.rstrip! "0" rescue f.slice! /0+\z/ # before Ruby 4.0 d << f end [ (negative? ? -1 : 1), d, 10, e] end |