-
Recent Posts
Recent Comments
Categories
Links
Daily Archives: May 13, 2018
division & modulus
a / b, a % b 當b為0時, behavior undefined,這邊討論其中一個operand為負數的情況 C89 整數除法(有負數情況下 implementation defined) -9/7 有可能是 -1 or -2 (rounded up or rounded down) 當然此時對應的 % 就會根據除法的結果而不同 (這邊討論整數的modulus,floating point可以參考fmod) 要符合 dividend = divisor * quotient + remainder -9 = 7 * … Continue reading
Posted in C Language, C++ Language
Leave a comment