giraffemedia Posted August 29, 2008 Share Posted August 29, 2008 Hello, i'm trying to round a number up from one decimal point to two but i'm not having any success. the number is 27.5 and i'd like to round it up to 27.50. Can I use the round function like so... $agency_discount = round((($bf_ad_rate/100) * $bf_agency_discount) ,2); echo $agency_discount; Regards James Link to comment https://forums.phpfreaks.com/topic/121847-solved-round-up-to-2-dp-from-1-dp/ Share on other sites More sharing options...
Fadion Posted August 29, 2008 Share Posted August 29, 2008 27.5 to 27.50 isn't a round up as far as i know, it is adding precision after the decimal point. You can use number_format(): <?php $nr = '27.5'; echo number_format($nr, 2, '.', ''); ?> Link to comment https://forums.phpfreaks.com/topic/121847-solved-round-up-to-2-dp-from-1-dp/#findComment-628630 Share on other sites More sharing options...
giraffemedia Posted August 29, 2008 Author Share Posted August 29, 2008 Brilliant. That's just the ticket GuiltyGear. Thanks James Link to comment https://forums.phpfreaks.com/topic/121847-solved-round-up-to-2-dp-from-1-dp/#findComment-628692 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.