Posted on September 8, 2008 by ubk
PHP Round Off Decimal or Convert to Decimal Point
Round Off Decimal
Round a number up or down or Round off a floating decimal point number using PHP’s functions round().
Example. round();
<?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.05
echo [...]
Filed under: Basic Scripts, Php-MySQL, php | Tagged: decimal, float, math, number_format, php, round | Leave a Comment »
Posted on August 17, 2008 by ubk
One of the most common tasks is to format a number for currency display- an integer followed by two decimals.
You may be tempted to use number rounding to first shift the number’s decimal places (via multiplication), round it, then shift the decimal back (via division) to pound the number into your hard earned dollar, though [...]
Filed under: Basic Scripts, Scripts, javascript | Tagged: decimal, digits, fixed, IE, javascript, NS, number, precision, significant, toFixed, toPrecision | Leave a Comment »