Positive integers that multiply to a negative value

前端 未结 9 1060
礼貌的吻别
礼貌的吻别 2021-02-07 05:17

I am learning C++ by reading Stroustrup\'s \"Principles and Practice Using C++\".

In the section about pre- and post-conditions there is the following example of functio

9条回答
  •  梦如初夏
    2021-02-07 05:28

    What comes to my mind is a signed overflow. It is undefined behavior but might yield a negative value.
    Try std::numeric_limits::max() and 2.

提交回复
热议问题