1. var someValue:Number = 2.0480531167374427;
  3. // want to show only 3 decimal places?
  4. trace(someValue.toFixed(3)); // outputs 2.048

An easy way to get rid of extra decimal values. This is useful when you want to show decimal values in text fields. I only recently noticed this in the docs, I used to do this type of thing:

  1. trace(int(someValue * 1000) / 1000);  // outputs 2.048

This entry was posted in Number and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted November 8, 2008 at 10:59 pm | Permalink

    Nice, I should read the docs more :P

  2. Posted November 9, 2008 at 5:49 pm | Permalink

    It would be easier if the docs were a bit more readable :)

  3. Posted November 10, 2008 at 1:19 pm | Permalink

    that is probably also true, especially the new docs in cs4, just plain terrible how its set up.

  4. Posted November 11, 2008 at 8:49 am | Permalink

    yeah. They should at least have an option to download the help locally…. maybe they do…. I heard about the help being browser only before it was released and I really hoped that they would change it…. too bad they didn’t.

Post a Comment

Your email is never published nor shared. Required fields are marked *