You can consider doing this:
$number=102.52;
$fraction=$number-floor($number);
$number=($number % 50)+$fraction;
Basically it's the exact solution you're suggesting, just that you don't
have to do any string stuff.
PHP's behaviour is normal - modulus is generally intended for
integers...
Bogdan
Consider the following:
$number = 102.52;
echo $number % 50;
echo bcmod( $number, 50 );
in both cases, it's spitting out "2". Why is it not spitting
out "2.52"? Is there a way I can get that information?
w/o having to parse the string, breaking it up, getting
the modulus and then adding it ba
at's all ;-)
Ahmad Anvari
- Original Message -
From: Michael Hall
To: PHP List
Sent: Tuesday, February 06, 2001 10:03 AM
Subject: [PHP] Modulus Formatting
> I can pull data out of a database using mysql_fetch_array and assemble
it like this using a w
> I can pull data out of a database using mysql_fetch_array and assemble
it like this using a while statement:
>
> $data
> $data
> $data
> etc ...
>
> What I'd like to do is assemble it like this:
>
> $data$data$data
> etc...
>
> In other words, I need a break () every three times through th
4%2 = 0
4 div 2 equals remainder 0
2 div 4 doesnt divide so your left with the remainder equal to what you
started with, 2
--
Chris Lee
Mediawaveonline.com
[EMAIL PROTECTED]
""Mike P"" <[EMAIL PROTECTED]> wrote in message
94qjq0$rde$[EMAIL PROTECTED]">news:94qjq0$rde$[EMAIL PROTECTED]..
Hi Mike!
On Thu, 25 Jan 2001, Mike P wrote:
> I know i'm a liitle slow but why does 2%4 = 2 and not 0 or 1
cause 4*0+2=2
> thanks
> Mike
> [EMAIL PROTECTED]
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-ma
I know i'm a liitle slow but why does 2%4 = 2 and not 0 or 1
thanks
Mike
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED
7 matches
Mail list logo