Integer division rounding with negatives in C++

前端 未结 4 1491
遇见更好的自我
遇见更好的自我 2020-11-29 11:07

Suppose a and b are both of type int, and b is nonzero. Consider the result of performing a/b in the follow

4条回答
  •  广开言路
    2020-11-29 11:45

    Just a comment. The current working draft for the C++ standard indeed corrects the "implementation-defined" issue and asks for truncation towards zero. Here is the committee's webpage, and here is the draft. The issue is at page 112.

提交回复
热议问题