Jump to content


Photo

Is there a way to limit the # of digits when using PHP to do arithmetic?


  • Please log in to reply
3 replies to this topic

#1 BadGoat

BadGoat
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 26 September 2006 - 12:44 PM

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!

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 26 September 2006 - 12:48 PM

number_format()

read up on it here

http://us3.php.net/m...mber-format.php

<?php
$number = 1.025654485;

echo number_format($number, 3);
?>

Ray

#3 BadGoat

BadGoat
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts

Posted 26 September 2006 - 12:51 PM

Thank you Ray, just what I needed ;D

#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 26 September 2006 - 12:54 PM

NP
:)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users