Posted By

sidneydekoning on 05/14/09


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

shuchii


Rounding of a Number to X decimals


 / Published in: ActionScript 3
 

  1. /* Returns a string representation of the number in fixed-point notation.
  2. Fixed-point notation means that the string will contain a specific number of digits after the decimal point, as specified in the fractionDigits parameter.
  3. The valid range for the fractionDigits parameter is from 0 to 20.
  4. Specifying a value outside this range throws an exception.
  5.  
  6. */
  7.  
  8. var num:Number = 4;
  9. trace(num.toFixed(2)); // 4.00
  10.  
  11. var num:Number = 7.31343;
  12. trace(num.toFixed(3)); // 7.313

Report this snippet  

You need to login to post a comment.