RE: % operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:andrew@copeandmcphetres.com]
Sent: Tuesday, August 12, 2003 3:04 PM
To: 'Alain Barthélemy'; php-db
Subject: RE:  % 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:cassandre@bartydeux.be]
>Sent: Tuesday, August 12, 2003 5:05 AM
>To: php-db
>Subject:  % 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
>cassandre@bartydeux.be
>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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux