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

心不动则不痛 提交于 2019-12-04 19:18:11

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/16501091/detect-ones-or-twos-complement-architecture-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!