Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    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
    New Coder
    Join Date
    Jan 2010
    Location
    Montreal
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi,
    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
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,227
    Thanks
    80
    Thanked 4,456 Times in 4,421 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:

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

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

    Is *THAT* what you want????

    Or do you want
    30569
    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
    ???
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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