Class com.innocuo.utils.LaoMath

Description

LaoUrl is a collection of math functions. It is intended to provide additional features that the default Math Object does not have. This class shouldn't be instantiated

Method Index

round()

Method Detail

round

static public function round(qnum:Number, qdecimal:Number, qdecimalmin:Number):Number

Round a number to a specific number of decimal places.

Example

 
  var num:Number=LaoMath.round(1.535,1); //returns 1.5
  var num2:Number=LaoMath.round(1.535,1,2); //returns 1.50
 
or (if the qdecimal number is negative) aproximate it to the closest group of ten, group of 100, group of 1000, etc
When qdecimal is less than zero, you'll always end with an integer, therefore, you won't ever see trailing decimal zeros

Example

 
  var num:Number=LaoMath.round(1535.51,-1); //returns 1540
  var num2:Number=LaoMath.round(1.51,-1,2); //returns 1540.00
 var num2:Number=LaoMath.round(1.51,-2,2); //returns 0.00
 

Parameters

qnumNumber to be rounded
qdecimalNumber of decimal places
qdecimalmin[optional] Minimum number of decimal places to display (if necessary, it'll add trailing zeros). Important: As it is the minimum, this parameter will get ignored if qdecimal is greater than qdecimalmin

Return

a rounded number to a specific number of decimal places [with optional trailing zeros]