Subject: number of decimal?
Posted By: hosefo81 Post Date: 2/10/2004 10:47:29 PM
For example, i have a calculation in the php page where 10/3=3.333333
How can i make the 3.33333 to be displayed as 3.33 (two decimal)?

Reply By: richard.york Reply Date: 2/11/2004 1:25:01 AM
quote:
From: http://www.php.net/round

float round ( float val [, int precision])

Returns the rounded value of val to specified precision (number of digits after the decimal point). precision can also be negative or zero (default).

Example 1. round() examples

<?php
echo round(3.4);         // 3
echo round(3.5);         // 4
echo round(3.6);         // 4
echo round(3.6, 0);      // 4
echo round(1.95583, 2);  // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2);    // 5.04
echo round(5.055, 2);    // 5.06
?>



hth,
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::


Go to topic 8497

Return to index page 951
Return to index page 950
Return to index page 949
Return to index page 948
Return to index page 947
Return to index page 946
Return to index page 945
Return to index page 944
Return to index page 943
Return to index page 942