Actionscript Math Round

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kraj
    New Member
    • May 2007
    • 5

    Actionscript Math Round

    hi all, i hav a problem in generatin script for rounded amount of decimal in flash
    e.g. if amount is Rs.25.68 den i want to display in round figur as Rs.26.00 so how i can do ? plz answer me soon..

    thnks & regards
    Kraj
  • kestrel
    Recognized Expert Top Contributor
    • Jul 2006
    • 1071

    #2
    To accomplish that, you would use math.round
    Heres a brief explanation with examples.
    Originally posted by http://www.actionscrip t.com
    The Math.round() method is used to round a number up or down to the nearest integer. Positive numbers with a decimal point less than 0.5, and negative numbers with a decimal point greater than 0.5 are rounded down. Postivie numbers with a decimal point greater than or equal to 0.5, and negative numbers with a decimal point less than or equal to 0.5 are round up.

    Example:
    Math.round(1.49 9999); // Returns 1
    Math.round(1.5) ; // Returns 2
    Math.round(1.6) ; // Returns 2
    Math.round(-5.49999); // Returns -5
    Math.round(-5.5); // Returns -5
    Math.round(-5.6); // Returns -6

    Comment

    • kestrel
      Recognized Expert Top Contributor
      • Jul 2006
      • 1071

      #3
      I edited your thread title to one that is more appropriate. Thank you.

      Comment

      • chunk1978
        New Member
        • Jan 2007
        • 224

        #4
        how is it possible to format a number for a dynamic textbox to always display at 2 decimal points using Actionscript 2.0.

        for this code, the dynamic text box is 2 levels deep (or whatever) as you can tell by the path...

        Code:
        var decimals = _root.DisplayMC.Display = 9;
        decimals.toFixed(2);
        yeah, and my code totally doesn't work at all...

        any thoughts?

        Comment

        Working...