Re: Numeric help needed

From: Date: Mon, 16 Jan 2012 02:42:10 +0000
Subject: Re: Numeric help needed
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-316306@lists.php.net to get a copy of this message
On 1/15/2012 9:24 PM, Robert Williams wrote:
On Jan 15, 2012, at 19:00, "Simon J Welsh"<simon@welsh.co.nz<mailto:simon@welsh.co.nz>> wrote: On 16/01/2012, at 2:48 PM, Chris Payne wrote: "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." 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"; round() rounds floating point which I suppose includes decimals, but decimal tends to have a fixed number of decimal places.
float *round* ( float $val [, int $precision= 0 [, int $mode= PHP_ROUND_HALF_UP ]] )

« previous php.general (#316306) next »