PDA

View Full Version : c ++ MODULUS OPERATOR

oblongmelon
10-14-2001, 11:05 PM
what do I do now!

Burzhui
10-14-2001, 11:09 PM
the modulus operator gives you the remainder, such as 15%6=3

6 goes into 15 2 times and 3 is left over

oblongmelon
10-14-2001, 11:12 PM
bless you.

Markel
10-14-2001, 11:13 PM
Are you wondering about the workings of a modulus operator in general, or something specific to c++? In general, a modulus operator works like this:

Divides the value of one expression by the value of another, and returns the remainder.

result = number1 % number2

where % is the modulus operator.

For example,

20 % 8 would return a value of 4

Burzhui
10-14-2001, 11:14 PM
Originally posted by Markel
Are you wondering about the workings of a modulus operator in general, or something specific to c++? In general, a modulus operator works like this:

Divides the value of one expression by the value of another, and returns the remainder.

result = number1 % number2

where % is the modulus operator.

For example,

20 % 8 would return a value of 4

wow dude i beat you by 4 minutes

and no prob oblongmelon

oblongmelon
10-14-2001, 11:17 PM
Thanks guys I appreciate it..(and so does Becca)

Markel
10-14-2001, 11:17 PM
Originally posted by Burzhui

wow dude i beat you by 4 minutes

I got distracted while I was typing my response.

But I think mine was better. :D

Burzhui
10-14-2001, 11:19 PM
Originally posted by Markel

I got distracted while I was typing my response.

But I think mine was better. :D

dude you kidding right, mine was right and straight to the point:P

Markel
10-14-2001, 11:24 PM
Originally posted by Burzhui

dude you kidding right, mine was right and straight to the point:P
Ever try to code:
15%6=varname

That's one reason why I think my answer was better. :D

Burzhui
10-14-2001, 11:25 PM
Originally posted by Markel

Ever try to code:
15%6=varname

That's one reason why I think my answer was better. :D
you mean varname = 15 % 6;

I gave it in words and an example... boo ya grandma:D

Markel
10-14-2001, 11:26 PM
Originally posted by Burzhui

you mean varname = 15 %6;
Look at your first response, and tell me what order you put it in!

Burzhui
10-14-2001, 11:28 PM
that was theory man

in mathematics 15%6=3

in programming

int result;
result = 0;
result = 15 % 6;

return result;

Markel
10-14-2001, 11:30 PM
Originally posted by Burzhui
that was theory man

Clarity is what it's all about, man. That's why I gave a CLEAR explanation. :)

Burzhui
10-14-2001, 11:33 PM

wanna duel??? :woo:

Markel
10-14-2001, 11:41 PM
:johnwoo2:

I won. :)

Burzhui
10-14-2001, 11:43 PM
Originally posted by Markel
:johnwoo2:

I won. :)

you missed plus in a ny case i'm a porn making :borg: and here you go :johnwoo2: and to finish you off :poke:

Markel
10-15-2001, 12:06 AM
Originally posted by Burzhui
you missed plus in a ny case i'm a porn making :borg: and here you go :johnwoo2: and to finish you off :poke:
That's lame. Just admit it - I'm better. :D

Burzhui
10-15-2001, 12:08 AM
Originally posted by Markel

That's lame. Just admit it - I'm better. :D

uhhh Cha:P

i answered first and it was good and understandable... but your input is obviously valuable as well, so shake on it, and move on.

Markel
10-15-2001, 12:11 AM
Ok. You can go back to your "weekend interests".

BrewMaster
10-15-2001, 02:25 AM
Haha. this useless exchange was pretty funny to read.

Markel
10-15-2001, 10:35 AM
Originally posted by BrewMaster
Haha. this useless exchange was pretty funny to read.
Well, I was going to let this thread drop off the bottom, but as long as you "woke it up", I'll add one more thing. There was a reason that I "pressed" this issue. It is true that Burzhui's answer was adequate to meet the need. However, as an answer to a programming language question, it was weak as compared to what followed. I have been writing software for 30 years now, and believe me, I have learned the value of code that is carefully planned out AND DOCUMENTED as compared to something that is just slammed together and happens to work. The first takes a little longer up front, but in the end it usually saves time, and in the long run (for maintainability) it is infinitely better.

So, if you are in pursuit of a career dealing with software development, take a lesson from someone who's been there.