MySQL wrote:

>   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.
>  
>
It depends on why you're storing this information in the first place. 
 If what you want is the precision of fractions (which you lose with 
floating point), then store the numerator and denominator.  If you want 
quick and dirty calculations at certain points in your code, store both ...

Example (where $x, $y are variables):
INSERT INTO FracTable (numerator, denominator, appxval) values ($x, $y, 
$x/$y);

-- 
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to