BadGoat Posted September 26, 2006 Share Posted September 26, 2006 Hello!I am wondering if there is a way to limit the # of digits when using PHP to perform mathematical computations? There are times when the output would have infinite points after the decimal, I am hoping there is a way to trim the # of digits... So far in my books I cannot find any info. Does anyone have a way to do this?Thanks! Link to comment https://forums.phpfreaks.com/topic/22093-is-there-a-way-to-limit-the-of-digits-when-using-php-to-do-arithmetic/ Share on other sites More sharing options...
craygo Posted September 26, 2006 Share Posted September 26, 2006 number_format()read up on it herehttp://us3.php.net/manual/en/function.number-format.php[code]<?php$number = 1.025654485;echo number_format($number, 3);?>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/22093-is-there-a-way-to-limit-the-of-digits-when-using-php-to-do-arithmetic/#findComment-98867 Share on other sites More sharing options...
BadGoat Posted September 26, 2006 Author Share Posted September 26, 2006 Thank you Ray, just what I needed ;D Link to comment https://forums.phpfreaks.com/topic/22093-is-there-a-way-to-limit-the-of-digits-when-using-php-to-do-arithmetic/#findComment-98870 Share on other sites More sharing options...
craygo Posted September 26, 2006 Share Posted September 26, 2006 NP :) Link to comment https://forums.phpfreaks.com/topic/22093-is-there-a-way-to-limit-the-of-digits-when-using-php-to-do-arithmetic/#findComment-98873 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.