Dysan Posted February 25, 2008 Share Posted February 25, 2008 Hi, With reference to decimal numbers, how do I keep only the first 2 numbers after the decimal point? <?php $number = 5.5; echo $number / 3; ?> Link to comment https://forums.phpfreaks.com/topic/92810-decimal-numbers/ Share on other sites More sharing options...
darkfreaks Posted February 25, 2008 Share Posted February 25, 2008 check number_format function Link to comment https://forums.phpfreaks.com/topic/92810-decimal-numbers/#findComment-475459 Share on other sites More sharing options...
Dysan Posted February 25, 2008 Author Share Posted February 25, 2008 Is it possible to just cut the numbers off after the 2 numbers following the decimal place? Link to comment https://forums.phpfreaks.com/topic/92810-decimal-numbers/#findComment-475479 Share on other sites More sharing options...
mainewoods Posted February 25, 2008 Share Posted February 25, 2008 if you want to just truncate after the 2 decimals, do this: $truncatednumber = floor($startnumber * 100) / 100; Link to comment https://forums.phpfreaks.com/topic/92810-decimal-numbers/#findComment-475514 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.