Forums Register Login

Why does (0 % n) not generate an arithmetic exceptoin

+Pie Number of slices to send: Send

The % operator (remainder/mod operator) return the remainder of the expression by dividing the first number with the second number.
If the first number is 0 (e.g. 0 % 5) the result is always 0. Why does this not return an ArithmeticException?
+Pie Number of slices to send: Send
Does 0 / 5 give you any exception?
+Pie Number of slices to send: Send
 

Ankit Garg wrote:Does 0 / 5 give you any exception?



Sorry my mistake.. i was thinking of 5/0 !
The human mind is a dangerous plaything. This tiny ad is pretty safe:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 768 times.
Similar Threads
Finding a prime factor
Increment Validator?
operator
assertions
Right Shift >> 33 on an int
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:54:54.