Re: Numeric help needed

From: Date: Mon, 16 Jan 2012 01:58:48 +0000
Subject: Re: Numeric help needed
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-316303@lists.php.net to get a copy of this message
On 16/01/2012, at 2:48 PM, Chris Payne wrote: > Hi Jason, > > I've tried lots of different things, including: > > echo "<br>" . round(68500, 1000) . " ROUNDED"; > > thinking that might be it, but i'm stumped > > This is the example I was given (And have to go by): > > "If the loan amount is $68500.00, the insurace will be based on > $69000.00 as the amount is always rounded up to the next $1000." > > Maybe i'm just looking at it wrong but i'm stumped. > > Chris The round() function only rounds decimal values. You can use this to emulate rounding to a near power of ten by dividing, rounding, then multiplying again. i.e. echo "<br>" . round(68500/1000) * 1000 . " ROUNDED"; --- Simon Welsh Admin of http://simon.geek.nz/

« previous php.general (#316303) next »