A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Fix a Number

  1. #1

    Fix a Number

    I want to know how can I fix a number? Suppose the out put of an expression is 43.4939393403 I want to remove all the number after the dot (including the dot).

    The out put of the expression might be 0.39348309483 or 393493.34349343948. Means the number before the decimal is not fixed. How can I do it?
    Thanks in advance.

  2. #2
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Math.round()

    will round up / down to the nearest integer.

    I do not know the syntax but you can ???
    subtract the 'int' value from the 'float' value
    If someone tells you it can't be done,
    it's probally because they don't know how.

  3. #3
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    And if you just want to get rid of whatever's after the decimal point, use Math.floor(), which alwasy rounds down.

  4. #4
    Living Proof mave_the_rave's Avatar
    Join Date
    May 2002
    Location
    East Dulwich
    Posts
    1,006
    Originally posted by chi-styler
    And if you just want to get rid of whatever's after the decimal point, use Math.floor(), which alwasy rounds down.
    Nice one.. I knew there was an easier way, but could not for the
    life of me remember what it was.
    If someone tells you it can't be done,
    it's probally because they don't know how.

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