Why not enforce 2's complement in C++?

后端 未结 4 929
囚心锁ツ
囚心锁ツ 2020-12-09 15:36

The new C++ standard still refuses to specify the binary representation of integer types. Is this because there are real-world implementations of C++ that don\'t use 2\'s co

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 15:54

    It seems to me that, even today, if you are writing a broadly-applicable C++ library that you expect to run on any machine, then 2's complement cannot be assumed. C++ is just too widely used to be making assumptions like that.

    Most people don't write those sorts of libraries, though, so if you want to take a dependency on 2's complement you should just go ahead.

提交回复
热议问题