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

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top