PDA

View Full Version : how to get the last digit of a number and add 1 to it?!


jarv
01-18-2010, 03:00 PM
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

FabriceB
01-18-2010, 04:05 PM
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! :thumbsup:

Old Pedant
01-18-2010, 07:30 PM
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
???