C Modulo Negative Number. Doing an integer division and then multiplying it again means finding the biggest number smaller than a that is dividable by n without a remainder. But things get a little more tricky when you throw negative numbers into the mix.
The modulo operation is supported for integers and floating point numbers. Modulo represents the remainder after division. In decimal, we use a minus sign to indicate a negative the main thing is, we get a result that won't fit.
Can a modulus be negative?
00001111 would still be 15, but that is contrasting an eight bit number with a four bit one. Hoisie opened this issue dec 21, 2009 · 6 comments. There you'll find that the result is as specified. Modulo and remainder operators differ with respect to negative values.
Nessun commento:
Posta un commento