• Advertisement

Archived

This topic is now archived and is closed to further replies.

tiny % questjun

This topic is 6061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

could any1 verify that this is correct plz (its in c++ ) 4 % 3 = 3 4 % 5 = 1 6 % 8 = 2 thanks

Share this post


Link to post
Share on other sites
Advertisement
4 mod 3 = 1

4 mod 5 = 4

6 mod 8 = 8

mod is modular division - remember grade school math well mod is just the remainder so

4 mod 3 is 1 remainder 1 so the answer is 1
4 mod 5 is 0 remainder 4 so the answer is 4
.
.
.

hope that helped


Smile, it won''t let you live longer, but it is funny when they die with a smile.

Share this post


Link to post
Share on other sites
And yes, you are correct, if you swap your operands...

3 % 4 = 3

5 % 4 = 1

8 % 6 = 2

G''luck,
-Alamar

Share this post


Link to post
Share on other sites
ok thanks

btw:
if you have a &ref to array[0], and you want &ref to point at array[1] .. would this be the correct way to change it:

&( ref += 1 )

or... ?
im not getting any errors when i do it like that, but i get some weird results..

Share this post


Link to post
Share on other sites
You cannot do pointer arithmetic on a reference. There might be a tricky way to do it but the whole point of references forbids it

You should use a pointer instead.

Seeya
Krippy

Share this post


Link to post
Share on other sites

  • Advertisement