Michael Campbell
4/19/2005 10:19:00 PM
On 4/19/05, Brian Schröder <ruby.brian@gmail.com> wrote:
> On 19/04/05, pmak@aaanime.net <pmak@aaanime.net> wrote:
> > The corresponding column in the MySQL database is of type DECIMAL(7,2),
> > but the corresponding Ruby structure came out as a String instead of a
> > decimal type. I haven't updated my database driver in a few years,
> > though; perhaps I'll look into that. Thanks.
> >
> >
>
> DECIMAL(7.2) should not be converted to a float value, as floats can't
> represent all instances of DECIMAL(7.2). For example 0.1 can not be
> represented as a float.
>
> irb(main):010:0> "%.18f" % 0.1
> => "0.100000000000000006"
In general, using non BCD type number encoding systems, *No* real
number that isn't a summation of powers of 2 can be represented by a
float.
By your logic then, does this mean that they just shouldn't be used
for any "DECIMAL(x, y)" (y > 0) field in a database?