I have an excel sheet that has number in cell that are formatted as #,##0.00.. Now, when I try to calculate those values using php round() function as round($number,2) , sometimes, the values are not exactly same, difference comes in the 2nd decimal place. What can be the problem? Has anyone experienced the same?
A:
I'm guessing here, but Excel may well round money in a certain direction as opposed to rounding it up or down about .5, which you're not doing with PHP. I'd presume it rounds down, change it to floor($number * 100) / 100
and see if you get the same answers (that's rounding the number down on the second decimal place, floor() doesn't support a precision parameter).
46Bit
2010-07-16 16:00:47
A:
what version of php are you using? older versions have non-standard rounding routine, prior to 5.2.7 they wouldnt always give the 'expected' results:
Ben Reisner
2010-07-16 16:16:40