[PHP] Fractions

2009-05-24 Thread Ron Piggott

Is there a way to remove the trailing '0'?

Also is there a way to have the original fraction display (1/4), as well
as have provision for 1/8 and 3/8 and 1/2, etc. display?

Width: 2.250 x Height: 6.250

Ron


Re: [PHP] Fractions

2009-05-24 Thread Mark Kelly
Hi.

On Sunday 24 May 2009, Ron Piggott wrote:
 Is there a way to remove the trailing '0'?

$width = number_format($width,2);

 Also is there a way to have the original fraction display (1/4), as well
 as have provision for 1/8 and 3/8 and 1/2, etc. display?

On this one I suspect you'd have to write your own function, but maybe 
someone else knows better.

HTH

Mark

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



Re: [PHP] Fractions

2009-05-24 Thread Nathan Rixham

Mark Kelly wrote:

Hi.

On Sunday 24 May 2009, Ron Piggott wrote:

Is there a way to remove the trailing '0'?


$width = number_format($width,2);


Also is there a way to have the original fraction display (1/4), as well
as have provision for 1/8 and 3/8 and 1/2, etc. display?


On this one I suspect you'd have to write your own function, but maybe 
someone else knows better.




yup you need to write your own functions - there was a request to 
internals a year or two ago, and it was decided that fractions were so 
easy to implement in userland and so rare that people should just 
implement them with there own code.


not expressly hard

echo '1/' . (1/0.25);

should be 1/4 i do believe

or in this scenario

$val = (float)'6.250';
$fract = $val - floor($val);
echo '1/' . (1/$fract);

the above code really won't do for 3/8's or suchlike though just a quick 
pointer - from here on your in userland :p


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



Re: [PHP] Fractions

2002-12-10 Thread Mike Smith
Stephen wrote:

I found how it works, and it doesn't put it into a mixed number. I work on
it this week and see if I can't fix it. Thanks for all the help people!


- Original Message -
From: Andrew Brampton [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 7:17 PM
Subject: Re: [PHP] Fractions




how about you try it to see what happens, and maybe learn how it works

Andrew
- Original Message -
From: Stephen [EMAIL PROTECTED]
To: Andrew Brampton [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Sent: Tuesday, December 10, 2002 12:11 AM
Subject: Re: [PHP] Fractions




Would this also print out as a mixed number if it should?


- Original Message -
From: Andrew Brampton [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 6:44 PM
Subject: Re: [PHP] Fractions




Well how would you do it on paper?

$numerator = 8;
$denominator = 12;

$factor = 1;

//Start at the greater of the 2, and loop down til you find a common


factor


for ($i=max($numerator,$denominator);$i1;$i--) {
   //Check if each number divided by $i has no remainder
   if (($numerator % $i) == 0  ($denominator % $i) == 0) {
   //Factor Found
   $factor = $i;
   break;
   }
   }

//Now a factor is found, divide by it
$numerator = $numerator / $factor;
$denominator = $denominator / $factor;

echo $numerator . '/' . $denominator;

The method might look like the above

Andrew

- Original Message -
From: Stephen [EMAIL PROTECTED]
To: Ray Hunter [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 11:20 PM
Subject: Re: [PHP] Fractions




But how do you find it in PHP?


- Original Message -
From: Ray Hunter [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 6:12 PM
Subject: Re: [PHP] Fractions




Just like math...find the greatest common denominator of the


numerator


and denominator and then divide each (numerator and denominator)


by


that


number...

ie: numerator = 8 and denominator = 12

so we have 8/12

then greatest common denominator is 4...

so 8/4 = 2 and 12/4 = 3

thus, 8/12 = 2/3


On Mon, 2002-12-09 at 15:55, Stephen wrote:


I know for a fact that you're all going to think, What the heck


does


he want fractions for!? I have a reason...I just won't tell


you.


:-P


My problem is this. I want to simplify a fraction to simplest


form


but


if I divide, I'll get a decimal which I can't use. How could I


put


it


in simplest form without displaying a decimal to the user and if


one


does come up, a mixed number?
Thanks,
Stephen Craton
http://www.melchior.us

What is a dreamer that cannot persevere? --


http://www.melchior.us




__


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


--

Ray Hunter
email: [EMAIL PROTECTED]
www: http://venticon.com


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




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





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





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








I use this to convert a decimal stored in a table.

function Fraction ($width)
{
list ($whole, $numerator) = explode ('.', $width);

$denominator = 1 . str_repeat (0, strlen ($numerator));

$GCD = GCD ($numerator, $denominator);

$numerator /= $GCD;
$denominator /= $GCD;

If ($numerator==0) {
return sprintf ('%d',$whole);
} else {
return sprintf ('%d %d/%d',
$whole, $numerator, $denominator);
}

}

function GCD ($a, $b)
{
while ( $b != 0)
  {
$remainder = $a % $b;
$a = $b;
$b = $remainder;
  }
return abs ($a);
}

So...

$width = 64.75;

Fraction($width);

Results:
64 3/4

You can add sup/sup and sub/sub for added effect.


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




[PHP] Fractions

2002-12-09 Thread Stephen



I know for a fact that you're all going to think, "What the 
heck does he want fractions for!?" I have a reason...I just won't tell you. 
:-P

My problem isthis. I want to simplify a fraction to 
simplest form but if I divide, I'll get a decimal which I can't use. How could I 
put it in simplest form without displaying a decimal to the user and if one does 
come up, a mixed number?
Thanks,Stephen Cratonhttp://www.melchior.us

"What is a dreamer that cannot persevere?" -- http://www.melchior.us
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Fractions

2002-12-09 Thread Ray Hunter
Just like math...find the greatest common denominator of the numerator
and denominator and then divide each (numerator and denominator) by that
number...

ie: numerator = 8 and denominator = 12

so we have 8/12

then greatest common denominator is 4...

so 8/4 = 2 and 12/4 = 3

thus, 8/12 = 2/3


On Mon, 2002-12-09 at 15:55, Stephen wrote:
 I know for a fact that you're all going to think, What the heck does
 he want fractions for!? I have a reason...I just won't tell you. :-P
  
 My problem is this. I want to simplify a fraction to simplest form but
 if I divide, I'll get a decimal which I can't use. How could I put it
 in simplest form without displaying a decimal to the user and if one
 does come up, a mixed number?
 Thanks,
 Stephen Craton
 http://www.melchior.us
  
 What is a dreamer that cannot persevere? -- http://www.melchior.us
 
 __
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
-- 

Ray Hunter
email:  [EMAIL PROTECTED]
www:http://venticon.com


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




Re: [PHP] Fractions

2002-12-09 Thread Stephen
But how do you find it in PHP?


- Original Message - 
From: Ray Hunter [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 6:12 PM
Subject: Re: [PHP] Fractions


 Just like math...find the greatest common denominator of the numerator
 and denominator and then divide each (numerator and denominator) by that
 number...
 
 ie: numerator = 8 and denominator = 12
 
 so we have 8/12
 
 then greatest common denominator is 4...
 
 so 8/4 = 2 and 12/4 = 3
 
 thus, 8/12 = 2/3
 
 
 On Mon, 2002-12-09 at 15:55, Stephen wrote:
  I know for a fact that you're all going to think, What the heck does
  he want fractions for!? I have a reason...I just won't tell you. :-P
   
  My problem is this. I want to simplify a fraction to simplest form but
  if I divide, I'll get a decimal which I can't use. How could I put it
  in simplest form without displaying a decimal to the user and if one
  does come up, a mixed number?
  Thanks,
  Stephen Craton
  http://www.melchior.us
   
  What is a dreamer that cannot persevere? -- http://www.melchior.us
  
  __
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 -- 
 
 Ray Hunter
 email: [EMAIL PROTECTED]
 www: http://venticon.com
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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




Re: [PHP] Fractions

2002-12-09 Thread Ray Hunter
If there are none in the math functions then you need to create your own
or do a search at google to see if anyone has created some functions
like that...



On Mon, 2002-12-09 at 16:20, Stephen wrote:
 But how do you find it in PHP?
 
 
 - Original Message - 
 From: Ray Hunter [EMAIL PROTECTED]
 To: Stephen [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Monday, December 09, 2002 6:12 PM
 Subject: Re: [PHP] Fractions
 
 
  Just like math...find the greatest common denominator of the numerator
  and denominator and then divide each (numerator and denominator) by that
  number...
  
  ie: numerator = 8 and denominator = 12
  
  so we have 8/12
  
  then greatest common denominator is 4...
  
  so 8/4 = 2 and 12/4 = 3
  
  thus, 8/12 = 2/3
  
  
  On Mon, 2002-12-09 at 15:55, Stephen wrote:
   I know for a fact that you're all going to think, What the heck does
   he want fractions for!? I have a reason...I just won't tell you. :-P

   My problem is this. I want to simplify a fraction to simplest form but
   if I divide, I'll get a decimal which I can't use. How could I put it
   in simplest form without displaying a decimal to the user and if one
   does come up, a mixed number?
   Thanks,
   Stephen Craton
   http://www.melchior.us

   What is a dreamer that cannot persevere? -- http://www.melchior.us
   
   __
   
   -- 
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  -- 
  
  Ray Hunter
  email: [EMAIL PROTECTED]
  www: http://venticon.com
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
-- 

Ray Hunter
email:  [EMAIL PROTECTED]
www:http://venticon.com


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




Re: [PHP] Fractions

2002-12-09 Thread Andrew Brampton
Well how would you do it on paper?

$numerator = 8;
$denominator = 12;

$factor = 1;

//Start at the greater of the 2, and loop down til you find a common factor
for ($i=max($numerator,$denominator);$i1;$i--) {
//Check if each number divided by $i has no remainder
if (($numerator % $i) == 0  ($denominator % $i) == 0) {
//Factor Found
$factor = $i;
break;
}
}

//Now a factor is found, divide by it
$numerator = $numerator / $factor;
$denominator = $denominator / $factor;

echo $numerator . '/' . $denominator;

The method might look like the above

Andrew

- Original Message -
From: Stephen [EMAIL PROTECTED]
To: Ray Hunter [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 11:20 PM
Subject: Re: [PHP] Fractions


 But how do you find it in PHP?


 - Original Message -
 From: Ray Hunter [EMAIL PROTECTED]
 To: Stephen [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Monday, December 09, 2002 6:12 PM
 Subject: Re: [PHP] Fractions


  Just like math...find the greatest common denominator of the numerator
  and denominator and then divide each (numerator and denominator) by that
  number...
 
  ie: numerator = 8 and denominator = 12
 
  so we have 8/12
 
  then greatest common denominator is 4...
 
  so 8/4 = 2 and 12/4 = 3
 
  thus, 8/12 = 2/3
 
 
  On Mon, 2002-12-09 at 15:55, Stephen wrote:
   I know for a fact that you're all going to think, What the heck does
   he want fractions for!? I have a reason...I just won't tell you. :-P
  
   My problem is this. I want to simplify a fraction to simplest form but
   if I divide, I'll get a decimal which I can't use. How could I put it
   in simplest form without displaying a decimal to the user and if one
   does come up, a mixed number?
   Thanks,
   Stephen Craton
   http://www.melchior.us
  
   What is a dreamer that cannot persevere? -- http://www.melchior.us
  
   __
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  --
 
  Ray Hunter
  email: [EMAIL PROTECTED]
  www: http://venticon.com
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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




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




Re: [PHP] Fractions

2002-12-09 Thread Stephen
Ok, I got one. It finds the great common divisor. I divide the numerator and
denominator by it. Then I do an if statement to see if the numerator is
greater then the denominator. If so, I divide them by each other. How can I
tell if there's a remainder, and if so, put it into a fraction in simpliest
form?


- Original Message -
From: Ray Hunter [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 6:38 PM
Subject: Re: [PHP] Fractions


 If there are none in the math functions then you need to create your own
 or do a search at google to see if anyone has created some functions
 like that...



 On Mon, 2002-12-09 at 16:20, Stephen wrote:
  But how do you find it in PHP?
 
 
  - Original Message -
  From: Ray Hunter [EMAIL PROTECTED]
  To: Stephen [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Monday, December 09, 2002 6:12 PM
  Subject: Re: [PHP] Fractions
 
 
   Just like math...find the greatest common denominator of the numerator
   and denominator and then divide each (numerator and denominator) by
that
   number...
  
   ie: numerator = 8 and denominator = 12
  
   so we have 8/12
  
   then greatest common denominator is 4...
  
   so 8/4 = 2 and 12/4 = 3
  
   thus, 8/12 = 2/3
  
  
   On Mon, 2002-12-09 at 15:55, Stephen wrote:
I know for a fact that you're all going to think, What the heck
does
he want fractions for!? I have a reason...I just won't tell you.
:-P
   
My problem is this. I want to simplify a fraction to simplest form
but
if I divide, I'll get a decimal which I can't use. How could I put
it
in simplest form without displaying a decimal to the user and if one
does come up, a mixed number?
Thanks,
Stephen Craton
http://www.melchior.us
   
What is a dreamer that cannot persevere? -- http://www.melchior.us
   
   
__
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   --
  
   Ray Hunter
   email: [EMAIL PROTECTED]
   www: http://venticon.com
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 --

 Ray Hunter
 email: [EMAIL PROTECTED]
 www: http://venticon.com




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




Re: [PHP] Fractions

2002-12-09 Thread Stephen
Would this also print out as a mixed number if it should?


- Original Message -
From: Andrew Brampton [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 6:44 PM
Subject: Re: [PHP] Fractions


 Well how would you do it on paper?

 $numerator = 8;
 $denominator = 12;

 $factor = 1;

 //Start at the greater of the 2, and loop down til you find a common
factor
 for ($i=max($numerator,$denominator);$i1;$i--) {
 //Check if each number divided by $i has no remainder
 if (($numerator % $i) == 0  ($denominator % $i) == 0) {
 //Factor Found
 $factor = $i;
 break;
 }
 }

 //Now a factor is found, divide by it
 $numerator = $numerator / $factor;
 $denominator = $denominator / $factor;

 echo $numerator . '/' . $denominator;

 The method might look like the above

 Andrew

 - Original Message -
 From: Stephen [EMAIL PROTECTED]
 To: Ray Hunter [EMAIL PROTECTED]
 Cc: PHP List [EMAIL PROTECTED]
 Sent: Monday, December 09, 2002 11:20 PM
 Subject: Re: [PHP] Fractions


  But how do you find it in PHP?
 
 
  - Original Message -
  From: Ray Hunter [EMAIL PROTECTED]
  To: Stephen [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Sent: Monday, December 09, 2002 6:12 PM
  Subject: Re: [PHP] Fractions
 
 
   Just like math...find the greatest common denominator of the numerator
   and denominator and then divide each (numerator and denominator) by
that
   number...
  
   ie: numerator = 8 and denominator = 12
  
   so we have 8/12
  
   then greatest common denominator is 4...
  
   so 8/4 = 2 and 12/4 = 3
  
   thus, 8/12 = 2/3
  
  
   On Mon, 2002-12-09 at 15:55, Stephen wrote:
I know for a fact that you're all going to think, What the heck
does
he want fractions for!? I have a reason...I just won't tell you.
:-P
   
My problem is this. I want to simplify a fraction to simplest form
but
if I divide, I'll get a decimal which I can't use. How could I put
it
in simplest form without displaying a decimal to the user and if one
does come up, a mixed number?
Thanks,
Stephen Craton
http://www.melchior.us
   
What is a dreamer that cannot persevere? -- http://www.melchior.us
   
   
__
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   --
  
   Ray Hunter
   email: [EMAIL PROTECTED]
   www: http://venticon.com
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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




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




Re: [PHP] Fractions

2002-12-09 Thread Stephen
I found how it works, and it doesn't put it into a mixed number. I work on
it this week and see if I can't fix it. Thanks for all the help people!


- Original Message -
From: Andrew Brampton [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 7:17 PM
Subject: Re: [PHP] Fractions


 how about you try it to see what happens, and maybe learn how it works

 Andrew
 - Original Message -
 From: Stephen [EMAIL PROTECTED]
 To: Andrew Brampton [EMAIL PROTECTED]
 Cc: PHP List [EMAIL PROTECTED]
 Sent: Tuesday, December 10, 2002 12:11 AM
 Subject: Re: [PHP] Fractions


  Would this also print out as a mixed number if it should?
 
 
  - Original Message -
  From: Andrew Brampton [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Monday, December 09, 2002 6:44 PM
  Subject: Re: [PHP] Fractions
 
 
   Well how would you do it on paper?
  
   $numerator = 8;
   $denominator = 12;
  
   $factor = 1;
  
   //Start at the greater of the 2, and loop down til you find a common
  factor
   for ($i=max($numerator,$denominator);$i1;$i--) {
   //Check if each number divided by $i has no remainder
   if (($numerator % $i) == 0  ($denominator % $i) == 0) {
   //Factor Found
   $factor = $i;
   break;
   }
   }
  
   //Now a factor is found, divide by it
   $numerator = $numerator / $factor;
   $denominator = $denominator / $factor;
  
   echo $numerator . '/' . $denominator;
  
   The method might look like the above
  
   Andrew
  
   - Original Message -
   From: Stephen [EMAIL PROTECTED]
   To: Ray Hunter [EMAIL PROTECTED]
   Cc: PHP List [EMAIL PROTECTED]
   Sent: Monday, December 09, 2002 11:20 PM
   Subject: Re: [PHP] Fractions
  
  
But how do you find it in PHP?
   
   
- Original Message -
From: Ray Hunter [EMAIL PROTECTED]
To: Stephen [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 6:12 PM
Subject: Re: [PHP] Fractions
   
   
 Just like math...find the greatest common denominator of the
 numerator
 and denominator and then divide each (numerator and denominator)
by
  that
 number...

 ie: numerator = 8 and denominator = 12

 so we have 8/12

 then greatest common denominator is 4...

 so 8/4 = 2 and 12/4 = 3

 thus, 8/12 = 2/3


 On Mon, 2002-12-09 at 15:55, Stephen wrote:
  I know for a fact that you're all going to think, What the heck
  does
  he want fractions for!? I have a reason...I just won't tell
you.
  :-P
 
  My problem is this. I want to simplify a fraction to simplest
form
  but
  if I divide, I'll get a decimal which I can't use. How could I
put
  it
  in simplest form without displaying a decimal to the user and if
 one
  does come up, a mixed number?
  Thanks,
  Stephen Craton
  http://www.melchior.us
 
  What is a dreamer that cannot persevere? --
 http://www.melchior.us
 
 
  __
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 --

 Ray Hunter
 email: [EMAIL PROTECTED]
 www: http://venticon.com


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


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




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




[PHP] Fractions

2002-11-16 Thread Stephen



I'm wanting to make a simple PHP script that converts Celsius 
to Farenheit, Farenheit to Celsius, Farenheit to Kelvin, and Celsius to Kelvin. 
I have the formula but it requires fractions. How can I use frations in PHP to 
multiply or divide? If you can't, how could I substitute doing so? 5/9 (F - 32) 
is the forumla to get Celsius to Farenheit if you need it.
Thanks,Stephen Cratonhttp://www.melchior.us

"Life is a gift from God. Wasting it is like destroying a gift you got from 
the person you love most." -- http://www.melchior.us
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Fractions

2002-11-16 Thread Mark Charette
You gotta be kidding me, no? When did you learn decimals? I think I started
by 3rd or 4th grade ...
  -Original Message-
  From: Stephen [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, November 16, 2002 1:36 PM
  To: PHP List
  Subject: [PHP] Fractions


  I'm wanting to make a simple PHP script that converts Celsius to
Farenheit, Farenheit to Celsius, Farenheit to Kelvin, and Celsius to Kelvin.
I have the formula but it requires fractions. How can I use frations in PHP
to multiply or divide? If you can't, how could I substitute doing so? 5/9
(F - 32) is the forumla to get Celsius to Farenheit if you need it.

  Thanks,
  Stephen Craton
  http://www.melchior.us

  Life is a gift from God. Wasting it is like destroying a gift you got
from the person you love most. -- http://www.melchior.us



Re: [PHP] Fractions

2002-11-16 Thread Marco Tabini
Supposing you want to display the numbers as decimal values:

$celsius = ($farenheit - 32) * 5 / 9;

Unless, of course, I did not understand your question properly.

Marco
-- 

php|architect - The magazine for PHP Professionals
The first monthly worldwide magazine dedicated to PHP programmers
Check us out on the web at http://www.phparch.com

On Sat, 2002-11-16 at 13:35, Stephen wrote:
 I'm wanting to make a simple PHP script that converts Celsius to
Farenheit, Farenheit to Celsius, Farenheit to Kelvin, and Celsius to
Kelvin. I have the formula but it requires fractions. How can I use
frations in PHP to multiply or divide? If you can't, how could I
substitute doing so? 5/9 (F - 32) is the forumla to get Celsius to
Farenheit if you need it.
 
 Thanks,
 Stephen Craton
 http://www.melchior.us
 
 Life is a gift from God. Wasting it is like destroying a gift you got from the 
person you love most. -- http://www.melchior.us
 
 

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



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




RE: [PHP] Fractions

2002-11-16 Thread Mark Charette
Well, seeing as you're in the 7th or 8th grade (at least according to your
Website) - my sincere apologies ...

Just use 5.0/9.0 in your formula.

Mark C.
  -Original Message-
  From: Stephen [mailto:[EMAIL PROTECTED]]
  Sent: Saturday, November 16, 2002 1:36 PM
  To: PHP List
  Subject: [PHP] Fractions


  I'm wanting to make a simple PHP script that converts Celsius to
Farenheit, Farenheit to Celsius, Farenheit to Kelvin, and Celsius to Kelvin.
I have the formula but it requires fractions. How can I use frations in PHP
to multiply or divide? If you can't, how could I substitute doing so? 5/9
(F - 32) is the forumla to get Celsius to Farenheit if you need it.

  Thanks,
  Stephen Craton
  http://www.melchior.us

  Life is a gift from God. Wasting it is like destroying a gift you got
from the person you love most. -- http://www.melchior.us



Re: [PHP] Fractions

2002-11-16 Thread Stephen
9/5 and 5/9 would be a repeating deicmal. I find fractions would be easier to multiply 
then a repeating deicmal. That's why I asked how to use fractions...
  - Original Message - 
  From: Mark Charette 
  To: Stephen ; PHP List 
  Sent: Saturday, November 16, 2002 1:44 PM
  Subject: RE: [PHP] Fractions


  Well, seeing as you're in the 7th or 8th grade (at least according to your Website) 
- my sincere apologies ...

  Just use 5.0/9.0 in your formula.

  Mark C.
-Original Message-
From: Stephen [mailto:[EMAIL PROTECTED]]
Sent: Saturday, November 16, 2002 1:36 PM
To: PHP List
Subject: [PHP] Fractions


I'm wanting to make a simple PHP script that converts Celsius to Farenheit, 
Farenheit to Celsius, Farenheit to Kelvin, and Celsius to Kelvin. I have the formula 
but it requires fractions. How can I use frations in PHP to multiply or divide? If you 
can't, how could I substitute doing so? 5/9 (F - 32) is the forumla to get Celsius to 
Farenheit if you need it.

Thanks,
Stephen Craton
http://www.melchior.us

Life is a gift from God. Wasting it is like destroying a gift you got from the 
person you love most. -- http://www.melchior.us


Re: [PHP] Fractions

2002-11-16 Thread Jason Wong
On Sunday 17 November 2002 03:09, Stephen wrote:
 9/5 and 5/9 would be a repeating deicmal. I find fractions would be easier
 to multiply then a repeating deicmal. 

But php doesn't care one bit (and neither should you) whether you use 

echo ( (5/9) * (80-32) );
OR  echo ( 0.6 * (80-32) );

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

/*
If the code and the comments disagree, then both are probably wrong.
-- Norm Schryer
*/


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