1. Modulus Operator

The modulus operator seems odd. Does it exist because of integer truncation?

2. >The modulus operator seems odd.
How so? After a division of two numbers there is a remainder, the modulus operator gives you that value.

-Prelude

3. And that is excelent to know for alot of mathematical stuff. Like finding prime numbers . finding out deviations etc,,,

4. What I should have asked is, "If we didn't have truncation, would we still have the modulus operator?"

5. If we didn't have truncation, finding the square root of one hundred and twenty would crash a computer.

6. Was the modulus operator developed to recover what is lost after integer truncation?

7. Not as far as i know. It is a free standing full fledge operator just as +-*/. I don't see any connection between the truncation and modolus

8. Yes it is a freestanding operator.
-Nic

9. How do u calculate a mod of something in terms of computer? Like how does the comp calculates it? Human can calculate a remainder of a number by doing working outs on a piece of paper i know.

10. >Human can calculate a remainder of a number by doing working
>outs on a piece of paper i know.

You can translate that algorithm to C.

9 / 4 = 2
4 * 2 = 8
9 - 8 = 1

so

9 % 4 = 9 - (9 / 4 * 4) = 1