note 105428 deleted from language.types.float by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Aug 2011 15:32:12 +0000 |
| Subject: | note 105428 deleted from language.types.float by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182527@lists.php.net to get a copy of this message | ||
Note Submitter: kakeakeai
----
@maxiumswarp at gmail dot com 27-Apr-2011 10:12
NEVER use anything BUT int (integer) for money! YOU CAN NOT AFFORD THE ERRORS!
Take $500.25:
1) Convert to int: 50025 (Store this)
2) divide by 100 (dollars): 500
3) mod by 100 (cents): 25
Store the int and calculate the dollars and cents ONLY to display it to a user. To add money USE THE
INT, THEN RE-CALCULATE your dollars and cents! PLEASE we don't need programs taking our hard
earned money too.