How do I define a constant equal to -2147483648?

前端 未结 2 1432
心在旅途
心在旅途 2020-12-22 11:50

I have a chunk of code generated by a script, and the code involves some integer constants. I ran into a strange problem: one of the constants is equal to -2147483648 (minim

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 12:09

    In C++ negative numbers are stored as positive number with (-) negative sign.

    That is why min int is defined as,

    #define INT_MIN (-2147483647 - 1)

    For int C++ does not understand 2147483648. So if possible you can also write 2147483648 as (-2147483647 - 1)

提交回复
热议问题