Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limit decimal place . . . 1

Status
Not open for further replies.

youthman

Programmer
Apr 28, 2004
49
US
Ok, all guru's . . . Yet ANOTHER Dumb question from the Youthman!!!! I need to limit the number of decimal places that a particular set of equations returns. (Like a dollar amount!)

Anyone with any bright ideas? I know that it should be rather mundain, but yet, I still cannot figure this out.

Please, No flames for my ignorance! :)

The youthman!
 
Take a look at the sprintf function for rounding. The below example rounds to 2 decimal places.

Code:
$rounded_num = sprintf("%.2f", $long_num);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top