Req #23498 [Opn->Wfx]: ceil() / floor() needs precision option

From: Date: Thu, 08 Jan 2015 22:31:32 +0000
Subject: Req #23498 [Opn->Wfx]: ceil() / floor() needs precision option
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-189759@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=23498&edit=1 ID: 23498 Updated by: ajf@php.net Reported by: junk at factory8 dot com Summary: ceil() / floor() needs precision option -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Math related Operating System: * PHP Version: * Block user comment: N Private report: N New Comment: As michael points out, you can do /100 and *100. Also, yes, don't do tax. This probably won't be added. Previous Comments: ------------------------------------------------------------------------ [2013-04-19 11:28:02] phpmpan at mpan dot pl In the context of bug 64675 and bug 64674 I dig up a 10 years old bug. Both ceil and floor functions make no sense for floating point numbers except a small subset of them. This is because either: - There is no element in the floating point numbers set that matches the result of these functions. - A relative difference between the result and the input is so small that it's irrelevant. As per original report: floating point numbers should NEVER be used for financial calculations. ------------------------------------------------------------------------ [2003-05-06 11:44:15] michael dot mauch at gmx dot de $x = 24.203; echo ceil($x*100)/100,"\n"; Would it be good enough if the manual would hint into that direction? ------------------------------------------------------------------------ [2003-05-05 18:45:28] junk at factory8 dot com ceil() should have a percision option. This would greatly help in rounding for tax. Example it is not easy to round $24.203 to $24.21 Thanks ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=23498&edit=1

« previous php.bugs (#189759) next »