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); Link to comment https://forums.phpfreaks.com/topic/81653-a-question-regarding-round/ 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. Link to comment https://forums.phpfreaks.com/topic/81653-a-question-regarding-round/#findComment-414774 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). Link to comment https://forums.phpfreaks.com/topic/81653-a-question-regarding-round/#findComment-414789 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. Link to comment https://forums.phpfreaks.com/topic/81653-a-question-regarding-round/#findComment-416654 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.