Re: sum
| From: | Austin Marshall | Date: | Mon, 06 May 2002 17:15:50 +0000 |
| Subject: | Re: sum | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96281@lists.php.net to get a copy of this message | ||
Mike Fifield wrote:
I am using the mysql sum() function to return the "sum" of a bunch of dolor amounts stored "float" values. But what I get back it something like this "98.199998855591" it is to precise. All I want is the dolor amounts added up and rounded up to the closest penny. Is there a better value type to use or a function that will return the information properly formatted. Mike Fifield Charles Schwab & Co, Inc. WARNING: All e-mail sent to or from this address will be received by the Charles Schwab corporate e-mail system and is subject to archival and review by someone other than the recipient.MySQL has a decimal column type which allows you to specify to how many decimal points the number is stored. http://www.mysql.com/doc/C/o/Column_types.html If you want to do it via PHP, you can format the number via number_format() and that will give you the 2 decimal points as well as the commas where needed. Also, both PHP and MySLQ have round() functions to format the numbers.