A literal number with a decimal point in it becomes a Float, e.g.
irb(main):002:0> 3.0.class
=> Float
Is there a way to make a literal like ‘3.0’ become something else,
e.g. a BigDecimal, automatically?
A literal number with a decimal point in it becomes a Float, e.g.
irb(main):002:0> 3.0.class
=> Float
Is there a way to make a literal like ‘3.0’ become something else,
e.g. a BigDecimal, automatically?
Hi,
In message “Re: Class of numeric literals”
on Thu, 12 Apr 2007 00:50:07 +0900, KM [email protected] writes:
|A literal number with a decimal point in it becomes a Float, e.g.
|
| irb(main):002:0> 3.0.class
| => Float
|
|Is there a way to make a literal like ‘3.0’ become something else,
|e.g. a BigDecimal, automatically?
I’m sorry but no. It would make the language flexible but fragile.
matz.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs