Jump to content

Archived

This topic is now archived and is closed to further replies.

BadGoat

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

Recommended Posts

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!

Share this post


Link to post
Share on other sites
number_format()

read up on it here

http://us3.php.net/manual/en/function.number-format.php

[code]<?php
$number = 1.025654485;

echo number_format($number, 3);
?>[/code]

Ray

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.