On Fri, May 19, 2006 1:27 pm, Sébastien Guay wrote: > I searched the archives but did not found anything. > > It seem that the round function behavior has changed in php 4.4.x (I > don't > have 4.4.1 handy for testing). > > In 4.3.11, the output of round("23.005",2) is 23.01 which is > mathematically > correct. > > In 4.4.2, the output is 23 which is not correct. The output of > round("23.0051",2) is correct though (23.01). > > Is there a workaround/patch for this?
The correctness of rounding kinda depends on which mathematical/historical model one subscribes to. There is at least one statistician's model of 'round' wherein a trailing '5' goes 'up' for preceding even numbers and 'down' for preceding odd numbers, to provide more symmetry in statistical analysis of rounding. Or, at least, that's how I recall it. If the rounding off is absolutely crucial to your application, you probably should switch to a dedicated mathematics extension such as BC_MATH or that new-fangled one whose name I never remember. You are only going to be disappointed time and again as PHP's "general" mathematics routines are altered for the masses who don't really care that much about the minutiae of a single point in the spectrum. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php