Home  >  Q&A  >  body text

c++ - C语言中,判断a+b与c的大小,if(a+b > c)为什么会判断错误?

高洛峰高洛峰2715 days ago659

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-17 14:40:34

    When the sum of a + b is too large, an overflow occurs. The long long here is signed long long. After overflow, it is truncated according to the number of digits of the long long, and then converted into a decimal number, which may become a negative number. Situation, then something went wrong.

    reply
    0
  • Cancelreply