|
-
Feb 25th, 2003, 05:51 PM
#8
Thread Starter
Hyperactive Member
Originally posted by jim mcnamara
We use base 10 numbers.
If you take a number like 5, 5 mod 10 gives you five
integer division retunrs whole numbers, so 12345/10 gives you 1234
Code:
1 2 3 4 5 <<- input
12345 % 10 = 5
12345/10 = 1234
1234 % 10 = 4
1234/10 = 123
123 % 10 = 3
123/10 = 12
12 % 10 = 2
12/10 = 1
1 % 10 = 1
5 4 3 2 1 <<- output
I figured it out a few minutes after I posted that question. So, each time you divide by ten, you move the decimal place over by one. And each time you use the modulus operation on the number, it returns the last number (which happens to be the remainder). Integer truncation gets rid of all the numbers past the decimal point. If I had spent a little longer thinking about what division and modulus does to number, I would have figured it out by myself. Oh well, thanks for the help guys.
My question now is, does this
just keep adding the result of that operation into the buffer and then display it to the screen when the loop ends?
Last edited by Comreak; Feb 25th, 2003 at 10:48 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|