Zero Divided by Zero (2003)
jsoftware.com
jsoftware.com
This is wrong. You need an extra %C on the left hand side for that identity to work:
((D%C)+(B%C))%C = (D+B) % C
It is far better in almost all cases to have it be something vaguely sensible than to have it pop out a virus that infects everything down the line.
Then don't use it. You can trap it, you know.
> It is far better in almost all cases to have it be something vaguely sensible than to have it pop out a virus that infects everything down the line.
It isn't better, because now your program produces incorrect results and you don't know about it.
Just write a safeDiv function that takes an argument for what the result should be if the denominator is zero.