A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Math HELP! 015 = 13? Number conversion problem

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    144

    Math HELP! 015 = 13? Number conversion problem

    Why does this happen?
    Code:
    trace(Number(015));
    // traces out 13 NOT! 15
    It is blowing my mind. The reason i care is that I have a NumericStepper component that the users can use to jump to a different question number in a quiz. When they type in 015 it goes to question 13 ... Same deal for text fields, Lables, etc. It is a number conversion issue.

    I am sure the the preceeding 0 is a switch of some kind for changing to a dirrerent number system like HEX or something, but I have no idea what is really happening or how to fix it. What i want is an INTEGER that strips off any preceeding Zeros and any Decimals.

    What Math operation will do these type of conversions? (tried Number, Math.floor, int(), etc with no luck)

    015 -> 15
    "017" -> 17
    0015 -> 15
    2.5 -> 2
    "17" -> 17


    thanks for any insight you can provide

    --mm

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    trace(parseInt("015", 10)); //traces 15

  3. #3
    Senior Member
    Join Date
    Sep 2000
    Posts
    144
    Thanks!!!

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