Re: [PHP] converting decimal to fraction and vice versa

2002-11-10 Thread Ernest E Vogelsinger
At 05:45 10.11.2002, Michael P. Carel said:
[snip]
is there any way to convert decimal numbers to fraction and fraction to 
decimal format. i need to convert the inputed fractional value in the field 
before inserting it to the mysql database, such us 1/2 = 0.5 .
[snip] 

?php
$in = '1/2';
eval(\$out = (double)$in;);
echo $in = $out\n;
?

Needs a lot of work before and after to check if things are right, but I
believe you get the idea...


-- 
   O Ernest E. Vogelsinger
   (\)ICQ #13394035
^ http://www.vogelsinger.at/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] converting decimal to fraction and vice versa

2002-11-09 Thread Michael P. Carel


hi to all;

is there any way to convert decimal numbers to fraction and fraction to decimal 
format. i need to convert the inputed fractional value in the field before inserting 
it to the mysql database, such us 1/2 = 0.5 .
thanx in advance.

regards,

mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] converting decimal to fraction and vice versa

2002-11-09 Thread Jason Wong
On Sunday 10 November 2002 12:45, Michael P. Carel wrote:
 hi to all;

 is there any way to convert decimal numbers to fraction and fraction to
 decimal format. i need to convert the inputed fractional value in the field
 before inserting it to the mysql database, such us 1/2 = 0.5 . thanx in
 advance.

Short answer: Yes.
Longer answer: No, not with the built-in functions.
Longest answer: You'll have to write your own functions/class, or find some 
existing ones - www.hotscripts.com, www.phpclasses.org, www.zend.com etc.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Card readers?  We don't need no stinking card readers.
-- Peter da Silva (at the National Academy of Sciencies, 1965, in a
   particularly vivid fantasy)
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php