Re: Formatting Decimals

From: Date: Mon, 11 Jan 2010 20:56:56 +0000
Subject: Re: Formatting Decimals
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-300996@lists.php.net to get a copy of this message
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote: > I have been asked to further modify the value to the nearest half cent. > > So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0 > If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it > gets rounded up to full cents. > > Can this be done fairly easily? Not knowing PHP well, I am not aware > of the logic to configure this accordingly. Yes, this can be done, but you'll need to write a function to do it yourself. I'd also suggest you look into the BCMath functions, at: http://us2.php.net/manual/en/book.bc.php Paul -- Paul M. Foster

« previous php.general (#300996) next »