Re: Fractions
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
Re: Fractions
From: MySQL [EMAIL PROTECTED] From: Madscientist [EMAIL PROTECTED] 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.. -- : 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 - 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
Re: Fractions
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm (http://www.ezmlm.org) X-Sender: [EMAIL PROTECTED]@teton.kitebird.com Date: Thu, 19 Sep 2002 08:54:55 -0500 From: Paul DuBois [EMAIL PROTECTED] News-Group: list.mysql Reply-To: [EMAIL PROTECTED] At 20:47 -0500 9/18/02, William Martell wrote: Hello. Can anyone tell me whether we can represent fractions in MySQL 4.0. I have data representing different lengths of objects measured in inches. Can I load this data as is into a field in MySQL or do I have to convert it first into an floating point interger or decimal value??? You could store them as strings, but you'd have to interpret them on the client side, most likely. In which case you might as well store them as reals, with char substitution (interpret). As reals, later when the inevitable desire occurs to add different lengths, it will be simple. - 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
RE: Fractions
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 ]-Original Message- ]From: MySQL [mailto:[EMAIL PROTECTED]] ]Sent: Thursday, September 19, 2002 7:51 PM ]To: [EMAIL PROTECTED] ]Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] ]Subject: Re: Fractions ] ] ] Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm ](http://www.ezmlm.org) ] X-Sender: [EMAIL PROTECTED]@teton.kitebird.com ] Date: Thu, 19 Sep 2002 08:54:55 -0500 ] From: Paul DuBois [EMAIL PROTECTED] ] News-Group: list.mysql ] Reply-To: [EMAIL PROTECTED] ] ] At 20:47 -0500 9/18/02, William Martell wrote: ] Hello. ] ] Can anyone tell me whether we can represent fractions in MySQL ]4.0. I have ] data representing different lengths of objects measured in ]inches. Can I ] load this data as is into a field in MySQL or do I have to ]convert it first ] into an floating point interger or decimal value??? ] ] You could store them as strings, but you'd have to interpret them on ] the client side, most likely. ] ]In which case you might as well store them as reals, with char ]substitution (interpret). As reals, later when the inevitable desire ]occurs to add different lengths, it will be simple. ] ]- ]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 ] ] - 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
Re: Fractions
From: Madscientist [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Fri, 20 Sep 2002 08:26:21 -0400 X-Priority: 3 (Normal) X-MSMail-Priority: Normal Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600. X-Declude-Spoolname: D13f214a.SMD News-Group: list.mysql Reply-To: [EMAIL PROTECTED] 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. ]-Original Message- ]From: MySQL [mailto:[EMAIL PROTECTED]] ]Sent: Thursday, September 19, 2002 7:51 PM ]To: [EMAIL PROTECTED] ]Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] ]Subject: Re: Fractions ] ] ] Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm ](http://www.ezmlm.org) ] X-Sender: [EMAIL PROTECTED]@teton.kitebird.com ] Date: Thu, 19 Sep 2002 08:54:55 -0500 ] From: Paul DuBois [EMAIL PROTECTED] ] News-Group: list.mysql ] Reply-To: [EMAIL PROTECTED] ] ] At 20:47 -0500 9/18/02, William Martell wrote: ] Hello. ] ] Can anyone tell me whether we can represent fractions in MySQL ]4.0. I have ] data representing different lengths of objects measured in ]inches. Can I ] load this data as is into a field in MySQL or do I have to ]convert it first ] into an floating point interger or decimal value??? ] ] You could store them as strings, but you'd have to interpret them on ] the client side, most likely. ] ]In which case you might as well store them as reals, with char ]substitution (interpret). As reals, later when the inevitable desire ]occurs to add different lengths, it will be simple. - 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
Fractions
Hello. Can anyone tell me whether we can represent fractions in MySQL 4.0. I have data representing different lengths of objects measured in inches. Can I load this data as is into a field in MySQL or do I have to convert it first into an floating point interger or decimal value??? Thanks in advance. William - 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
Re: Fractions
At 20:47 -0500 9/18/02, William Martell wrote: Hello. Can anyone tell me whether we can represent fractions in MySQL 4.0. I have data representing different lengths of objects measured in inches. Can I load this data as is into a field in MySQL or do I have to convert it first into an floating point interger or decimal value??? You could store them as strings, but you'd have to interpret them on the client side, most likely. Thanks in advance. William - 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
Fractions
sql,query,database,odbc Hello All, Can anyone tell me whether I can represent fractions in MySQL 4. I have data representing different lengths of objects measured in inches. Can I load this data as is into a field in MySQL and still retain the same value or do I have to convert it first to a float or decimal value?? What type of data type will the field be bigint, int, decimal??? The measurements are small, for example 2 1/2 inches, 3 1/8 inches. Thanks in advance - 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
Re: Fractions
you could store them as 3 integers. The integral part, the numerator of the fraction and the denominator of the fraction - then interpret them at the client side. William Martell wrote: sql,query,database,odbc Hello All, Can anyone tell me whether I can represent fractions in MySQL 4. I have data representing different lengths of objects measured in inches. Can I load this data as is into a field in MySQL and still retain the same value or do I have to convert it first to a float or decimal value?? What type of data type will the field be bigint, int, decimal??? The measurements are small, for example 2 1/2 inches, 3 1/8 inches. Thanks in advance -- David Patte Relative Data, Inc. -- MyStars! 2.7 Shareware for Stargazers Website #1: http://www.relativedata.com/ Website #2: http://www.mystarslive.com/ 24 Hr Bus. Phone/Fax: 1 (613) 728-4240 - 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
Re: Fractions
On Wed, 18 Sep 2002, William Martell wrote: Can anyone tell me whether we can represent fractions in MySQL 4.0. I have data representing different lengths of objects measured in inches. Can I load this data as is into a field in MySQL or do I have to convert it first into an floating point interger or decimal value??? Did you consider storing a fraction using 2 integers? That's the way we did it many years ago in Forth. Thomas Spahni -- sql, query - 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
Re: Fractions
[ this mysql spam filter sucks -- including a query in one's message isn't good enough ] [EMAIL PROTECTED] wrote: you could store them as 3 integers. The integral part, the numerator of the fraction and the denominator of the fraction - then interpret them at the client side. This would even have the benefit of making the whole thing sortable (with approximations) ... # val_i := integer; val_n := numerator; val_d := denominator SELECT id FROM table WHERE val_i + (val_n / val_d) 10; -- 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