dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Decimal places

  1. #1
    Junior Member
    Join Date
    Jan 2003
    Posts
    20

    Decimal places

    Can anybody tell me how to limit the decimal places to 2 in the dyanamic text field? I have given a dynamic field a variable name. and I created a button to change its value by 0.1. But when I click the button the text box shows me many number of decimal places after a point. I want to limit it to 2 places
    Thanks

  2. #2
    Senior Member
    Join Date
    Sep 2001
    Posts
    443
    multiply by (10 to the power of number of dp's required), round the number, then divide by the same power of ten.

    swills

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    or, in code:

    code:
    // round to two places (10 squared is 100)
    number = 3.14598;
    rounded = Math.round(number*100)/100;



    - n.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center