Cep Posted December 14, 2007 Share Posted December 14, 2007 Hello, My question is to do with the php round function. From what I can glean the function should round up or down to the nearest integer. So 4.3 will be 4, 4.4 till be 4, 4.5 will be 5. However I have come across occasions where values that are for example 0.375 are being rounded to 0.37 and not 0.38. Is this because in the optional parameter I am doing, $mynum = round($num, 2); Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 14, 2007 Share Posted December 14, 2007 Yes its because of the optional parameter it states the amount of decimal points. Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted December 14, 2007 Share Posted December 14, 2007 That's strange. It should round and not truncate. It might be a bug. I get the expected output when trying echo round(0.375, 2); (0.38). Quote Link to comment Share on other sites More sharing options...
Cep Posted December 17, 2007 Author Share Posted December 17, 2007 I will look into it a bit further and see what I can come up with, thanks for looking into it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.