Detect one's or two's complement architecture in C++?

后端 未结 1 1734
[愿得一人]
[愿得一人] 2020-12-16 17:06

What is the most reliable way to detect whether the architecture uses one\'s or two\'s complement representation in C++?

相关标签:
1条回答
  • 2020-12-16 17:40

    You shouldn't have to worry - there aren't too many ones complement machines out there :)

    But the easiest thing might be to compare "-1" with ~0.

    0 讨论(0)
提交回复
热议问题