Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Thanked 0 Times in 0 Posts

    how to get the last digit of a number and add 1 to it?!

    ok so I have 30568

    in ASP how do i get the last digit eg here it is 8

    Then I want to change this to a 9 by adding 1

  2. #2
    New Coder
    Join Date
    Jan 2010
    Thanked 0 Times in 0 Posts
    I usually don't like to answer with another question but in this case I think it might help you get a jump start...

    When you found your answer for the example you provided, how did you go about it mathematically?

    Now... assuming you found that using mod, google is always your best option to find your answer (and this well before posting) ...

    That said, try the following search: asp mod function

    you should find exactly what you need from there!

    hope this helps!

    P.S.: I know you probably expected a direct answer to your question but this is fairly close to it, simply trying to help you find your answers more quickly and efficiently on your own...

    Have a nice day!

  3. #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    I doubt seriously that Jarv found it mathematically, at all.

    I'm sure he just looked at the string of digits and picked out the last one.

    My question to Jarv is more fundamental:

    last digit is 8
    bump it by 1 and it is 9

    last digit is 9
    bump it by 1 and it is 10

    Is *THAT* what you want????

    Or do you want
    last digit is 9
    bump it by 1 and it is 10, but then you only want the last digit of that so answer is 0.

    Is *THAT* what you want???

    Finally, when you get the last digit bumped by 1, do you want to put it back on the end of the number???

    That is, do you *REALLY* want
    30568 ==>> 30569
    30569 ==>> 30560
    Be yourself. No one else is as qualified.


Posting Permissions

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