Re: [PHP] Re: Problem with number_format
Martin Geisler wrote: My PHP manual (from a Debian package) has the following note on the page for round(): Caution When rounding on exact halves round() rounds down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The reason behind rounding half the values down and the other half up is to avoid the classical banking problem where if you always rounded down you would be stealing money from your customers, or if you always rounded up you would end up over time losing money. By averaging it out through evens and odds you statistically break even. I'm surprised with this note on manuals. I do not know in other places, but in the European Union there are laws and directives that obligates to always round to 5/4 in currency operations (Specially on Euro Conversions). It means that 5 and above rounds always up, anything bellow 5 rounds always down. So, 0,655 must round to 0,66 and 0,654 must round to 0,65. In this case, nothing to do: It is the law. And ... the funny note on laws (almost on spanish laws) says that computer programs wich round in a different way are not considered valid reasons to not round as stated above. Regards, Jordi. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with number_format
* Thus wrote Martin Geisler ([EMAIL PROTECTED]): My PHP manual (from a Debian package) has the following note on the page for round(): Caution When rounding on exact halves round() rounds down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. The reason behind rounding half the values down and the other half up is to avoid the classical banking problem where if you always rounded down you would be stealing money from your customers, or if you always rounded up you would end up over time losing money. By averaging it out through evens and odds you statistically break even. This is a documentation error. And is not on the current documentation. Curt -- I used to think I was indecisive, but now I'm not so sure. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Problem with number_format
Martin Geisler wrote: My PHP manual (from a Debian package) has the following note on the page for round(): Caution When rounding on exact halves round() rounds down on evens and up on odds. If you want to always force it in one direction on a .5 (or .05 in your case) add or substract a tiny fuzz factor. I'm surprised with this note on manuals. I do not know in other places, but in the European Union there are laws and directives that obligates to always round to 5/4 in currency operations (Specially on Euro Conversions). It means that 5 and above rounds always up, anything bellow 5 rounds always down. So, 0,655 must round to 0,66 and 0,654 must round to 0,65. In this case, nothing to do: It is the law. So it seems a PHP4 bug, now corrected in PHP5-RC. Waiting for a stable release of PHP5, it seems I need to add a tiny fuzz factor where 3rd decimal is 5. I'm working on Euro conversions, this isn't a good new...:( Thanks, ciao Francesco --- Spazio ILLIMITATO per la tua Email, Scanner Antivirus, Antispam, Backup e POP3. Prova la nuova Email di superEva: http://webmail.supereva.it/ --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php