RE: [PHP-DB] % operator
Well, it looks like your previous response was correct, but $a%$b in this case returns 4, not the 0.8 as intended ... fmod($a, $b) (I have php 4.1.2, so I can't test fmod()) will probably return 0.8 though. As a side note, this message seems a little off-topic ... though it is PHP, it has nothing to do with databases. :) Regards, Matt. -Original Message- From: Andrew D. Luebke [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 3:04 PM To: 'Alain Barthélemy'; php-db Subject: RE: [PHP-DB] % operator Although now that I look at: http://us4.php.net/manual/en/language.operators.arithmetic.php You'll see that $a % $b resturns the modulus so that is probably the easiest. Andrew, At 11:43 AM 8/12/2003, you wrote: There's probably a better way to do this, but to retrieve only the 0.8 from 24/5 try this: ($a/$b)-floor($a/$b) Regards, Matt. -Original Message- From: Alain Barthélemy [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 5:05 AM To: php-db Subject: [PHP-DB] % operator Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] % operator
There's probably a better way to do this, but to retrieve only the 0.8 from 24/5 try this: ($a/$b)-floor($a/$b) Regards, Matt. -Original Message- From: Alain Barthélemy [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 5:05 AM To: php-db Subject: [PHP-DB] % operator Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] % operator
On Tuesday 12 August 2003 10:39 am, Phil Driscoll wrote: The modulus is the remainder after division hence 5 into 24 goes 3 times with a remainder of 4, oops - 4 times with a remainder of 4 :( -- Phil Driscoll -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] % operator
The easiest way would probably be to use the fmod function. http://us3.php.net/manual/en/function.fmod.php Andrew. At 11:43 AM 8/12/2003, Matthew Moldvan wrote: There's probably a better way to do this, but to retrieve only the 0.8 from 24/5 try this: ($a/$b)-floor($a/$b) Regards, Matt. -Original Message- From: Alain Barthélemy [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 5:05 AM To: php-db Subject: [PHP-DB] % operator Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] % operator
The % is called the Modulus operator. It is very briefly explained in the PHP manual in table 11-2. In your example, $mod = $a % $b == $mod = 0.8 It is a very easy operator to use. Doug On Tue, 12 Aug 2003 11:04:39 +0200, Alain Barthélemy wrote: Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] % operator
Although now that I look at: http://us4.php.net/manual/en/language.operators.arithmetic.php You'll see that $a % $b resturns the modulus so that is probably the easiest. Andrew, At 11:43 AM 8/12/2003, you wrote: There's probably a better way to do this, but to retrieve only the 0.8 from 24/5 try this: ($a/$b)-floor($a/$b) Regards, Matt. -Original Message- From: Alain Barthélemy [mailto:[EMAIL PROTECTED] Sent: Tuesday, August 12, 2003 5:05 AM To: php-db Subject: [PHP-DB] % operator Hello, If you have $a = 24; $b = 5; and $c = $a/$b; === $c = 4.8 To retrieve the .8 (reste in french) I saw instruction: $a%$b Where can I find a manual for this '%' operator? Of course I already looked in all the Php manuals (operators, etc ...). Thanks, -- Alain Barthélemy [EMAIL PROTECTED] http://bartydeux.be Linux User #315631 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] % operator
On Tuesday 12 August 2003 10:27 am, Doug Thompson wrote: The % is called the Modulus operator. It is very briefly explained in the PHP manual in table 11-2. In your example, $mod = $a % $b == $mod = 0.8 The modulus is the remainder after division hence 5 into 24 goes 3 times with a remainder of 4, hence $mod=25%4 gives $mod=4 Cheers -- Phil Driscoll -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] % operator
One day I'll learn to wait until two cups of coffee before attempting to post replies. On top of which, I have no idea where 0.8 came from. 8-/ Sorry for the confusion factor. Doug On Tue, 12 Aug 2003 10:47:21 +0100, Phil Driscoll wrote: On Tuesday 12 August 2003 10:39 am, Phil Driscoll wrote: The modulus is the remainder after division hence 5 into 24 goes 3 times with a remainder of 4, oops - 4 times with a remainder of 4 :( -- Phil Driscoll -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php