A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: a few digits

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Location
    London NW10
    Posts
    136
    hi,

    how would i get the last 4 digits of a 7 digit number.

    would love some help on this.

    cheers.

    mydo

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Hi,

    This will get the last 4 digits of a number of any length

    digitsWanted = 4; // how many digits should be found
    number = 8675252; // random 7 digit number to test
    number = number.toString();
    len = number.length; // how many digits in the number
    start = len - digitsWanted;
    lastDigits = number.substr(start, digitsWanted);
    trace(lastDigits); // in this case displays 5252

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Location
    London NW10
    Posts
    136
    fantastic

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