quillspirit Posted October 16, 2006 Share Posted October 16, 2006 I know I can round to a whole number with [code]ceil[/code] - but how can I round the just the hundredth? (Second number)...Like 1.33333333333333to1.33?Thanks for the help :) Link to comment https://forums.phpfreaks.com/topic/24065-rounding-decimals/ Share on other sites More sharing options...
cows Posted October 16, 2006 Share Posted October 16, 2006 I think..[code]round("1.33333333333333", 2);[/code] Link to comment https://forums.phpfreaks.com/topic/24065-rounding-decimals/#findComment-109320 Share on other sites More sharing options...
quillspirit Posted October 16, 2006 Author Share Posted October 16, 2006 *EDIT*Thanks, that did the trick :) Link to comment https://forums.phpfreaks.com/topic/24065-rounding-decimals/#findComment-109325 Share on other sites More sharing options...
xsist10 Posted October 16, 2006 Share Posted October 16, 2006 Just remember:[code]<?php// ceil rounds upecho ceil("1.00001");// will print out 2// floor rounds downecho ceil("1.99999");// will print out 1?>[/code] Link to comment https://forums.phpfreaks.com/topic/24065-rounding-decimals/#findComment-109393 Share on other sites More sharing options...
redarrow Posted October 16, 2006 Share Posted October 16, 2006 Heres a nice little example for you.[code]<?php$computer_price=ceil("1.9999");$computer_price=sprintf("\$%01.3f",$computer_price);echo " Please Pay $computer_price for your pc"; ?>[/code] Link to comment https://forums.phpfreaks.com/topic/24065-rounding-decimals/#findComment-109403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.