C语言整数除法遵守截断truncation规则而非四舍五入 C99规定使用趋零截断,比如-3.8转化为-3
C
truncation
C99
-3.8
-3
#include <stdio.h> int main(int argc, char const *argv[]) { int a = 5; int b = 3; printf("%d\n",a/b); } /** * save as test1.c * $gcc test1.c * $./a.out * 1 */
ref:“C Primer Plus 6”
“C Primer Plus 6”