List:General Discussion« Previous MessageNext Message »
From:Jan Steinman Date:September 22 2002 10:38am
Subject:Re: Fractions
View as plain text  
>From: MySQL <mysql@stripped>
>
>   From: "Madscientist" <madscientist@stripped>
>
>   You might also consider using two integer type fields - one for the
>   numerator and another for the denominator. This way storage and recovery are
>   easy and the mathematics are wide open.
>   _M
>
>I suspect that a float add is faster than 3 integer multiplies and
>sum.

Ah, but it is not as accurate!

If the original poster knows he needs fractions, he won't be happy with float.

Just as one should NEVER use floating point to represent money, one should NEVER use it
for representing fractions that need to be precise. For example, (1/3 as a float) * 3
will come out to 0.99999999.

-- 
: Jan Steinman -- nature photography: <http://www.Bytesmiths.com>
: Bytesmiths -- artists' services: <http://www.Bytesmiths.com/Services>
: Join the forums at <http://www.Bytesmiths.com/wiki>

Thread
FractionsWilliam Martell19 Sep
  • Re: FractionsPaul DuBois19 Sep
    • Re: FractionsMySQL20 Sep
      • RE: FractionsMadscientist20 Sep
        • Re: FractionsMySQL21 Sep
        • Re: FractionsMichael T. Babcock23 Sep
  • Re: FractionsThomas Spahni19 Sep
Re: FractionsMichael T. Babcock19 Sep
Re: FractionsJan Steinman22 Sep