I'm not sure if you understood what I was trying to do... I went ahead a
wrote something... if there's something else out there I should use, let me
know:



//this only works for positive numbers where input > divisor (so far)!!

function alt_floor ( $input , $divisor ) { 

    if ( $input % $divisor == 0 ) {
      return $input;
    }
    
    else {
        for ( $i = $divisor ; $i < $input ; $i+=$divisor ) {}
        
        $i -= $divisor;
        return $i;
    }
}

$y = alt_floor ( 165 , 20 ); $y = 160
$y = alt_floor ( 10 , 3 ); $y = 9
$y = alt_floor ( 701 , 10 ); $y = 700
$y = alt_floor ( 15 , 6 ); $y = 12
$y = alt_floor ( 15 , 3 ); $y = 15




$floor_val = 6 * ((int) 15/6) // yielded 15 for me... not what I was going
for.

---------------------
John Asendorf - [EMAIL PROTECTED]
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
Nullum magnum ingenium sine mixtura dementiae fuit


> -----Original Message-----
> From: cybot [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 28, 2003 3:03 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Re: Looking for something like floor() 
> only to round
> to a nearest div
> 
> 
> just use
> 
> $floor_val = 6 * ((int) 15/6)
> 
> John Asendorf wrote:
> > I'm looking for a function like floor() only I want it 
> rounded to a number
> > that is divisible by another number.  For instance, if the 
> divisor is 6,
> > alt_floor ( 15 , 6 ) would yield 12 where 15 is the input 
> and 6 is the
> > divisor.  Or, alt_floor ( 174 , 20 ) would yield 160...
> > 
> > Anyone already do something like this?
> > 
> > Thanks,  John
> > 
> > ---------------------
> > John Asendorf - [EMAIL PROTECTED]
> > Web Applications Developer
> > http://www.lcounty.com - NEW FEATURES ADDED DAILY!
> > Licking County, Ohio, USA
> > 740-349-3631
> > Nullum magnum ingenium sine mixtura dementiae fuit
> 
> -- 
> Sebastian Mendel
> 
> [EMAIL PROTECTED]
> 
> www.sebastianmendel.de
> www.tekkno4u.de
> www.nofetish.com
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

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

Reply via email to