![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
you can use integer division and modulus to break numbers apart. a classic example would be to convert decimal to binary. another example would be if you wanted to "make change". a solution rather easy for the human brain...how many coins of each type would you give to someone who needed 41 cents back in change? for those of us who've "worked a register" we all know it's one of each. one quarter, one dime, one nickel, and one penny. besides being the key to data encryption...modulus can help you divide numbers like you divide strings. in review...it's the REMAINDER after integer division. if you divide 1 by 2...2 goes into 1 zero times...leaving a remainder of two. it's a rather magical function. learn to use it.
as to "what can be evenly divided by what" let's restate, the syntax is: (for C/C++) #include <iostream>
using namespace std;
int main(){
int x, y;
cout<<"enter 2 numbers"<<endl;
cin>>x>>y;
if (x % y ==0)
{
cout<<"yay! this shit is true!!!"<<endl;
}
if (x % y != 0)
{
cout<<"crap!!! it's false!!!"<<endl;
}
system("pause");
}
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
|
|
#12 |
|
Expert Programmer
|
Most easily said, modulus return the remainder after division. Remember how you used to do division in grade 3 and 4, they wouldn't make you calculate all those decimals, instead you just specific the remainder... so yup, it is that simple.
__________________
Clifford Matthew Roche <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
|
|
#13 | |
|
Programmer
Join Date: Nov 2005
Location: Moseley, Birmingham, England, Earth
Posts: 51
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Let's see...post 12 repeats posts 2 and 5 and post 13 repeats post 9. Next?
![]()
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#15 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Post 15 repeats post 14. HAH you didn't see that one coming, did you?
![]()
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#16 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
We finally introduced recursion into the thread
.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#17 | |
|
Newbie
Join Date: Nov 2005
Posts: 9
Rep Power: 0
![]() |
:p
Quote:
|
|
|
|
|
|
|
#18 | |||||||||||
|
Hobbyist Programmer
Join Date: Oct 2005
Posts: 211
Rep Power: 4
![]() |
Quote:
(my appologies to all) |
|||||||||||
|
|
|
|
|
#19 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
ROFL, it's pretty funny Mbirchmeier, and looks nice as well
![]()
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#20 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Looks like one of the TO posts, MB
.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|