Edit report at http://bugs.php.net/bug.php?id=36310&edit=1
ID: 36310 Updated by: [email protected] Reported by: daedalon at users dot sourceforge dot net Summary: floor() and ceil() to take precision argument -Status: Open +Status: Closed Type: Feature/Change Request -Package: Feature/Change Request +Package: Math related Operating System: any PHP Version: 5.1.2 -Assigned To: +Assigned To: jani Block user comment: N Private report: N New Comment: Same as bug #23498 Previous Comments: ------------------------------------------------------------------------ [2006-02-07 08:26:17] [email protected] Marking as Feature Request. ------------------------------------------------------------------------ [2006-02-07 02:05:18] daedalon at users dot sourceforge dot net Description: ------------ Since PHP 4, round() takes precision as a parameter. This would be very useful for floor() and ceil() too for there are cases when one wants to round fractions up or down to certain precision. By the way the documentation for floor() and ceil() could make a note of how the functions act for zero decimals to increase clarity. Currently the behavior could be too easily misinterpreted by someone non-native English reader. Reproduce code: --------------- echo round(5.055, 2); // Prints 5.06 as expected echo floor(15.075, 2); // Should print 15,07 but prints 15 echo ceil(3.041, 2); // Should print 3,05 but prints 4 Expected result: ---------------- echo round(5.055, 2); // Prints 5.06 as expected echo floor(15.075, 2); // Should print 15,07 but prints 15 echo ceil(3.041, 2); // Should print 3,05 but prints 4 Actual result: -------------- echo round(5.055, 2); // Prints 5.06 as expected echo floor(15.075, 2); // Should print 15,07 but prints 15 echo ceil(3.041, 2); // Should print 3,05 but prints 4 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=36310&edit=1
