在 C++ 中检测一个或两个的补码架构? [英] Detect one's or two's complement architecture in C++?

查看:15
本文介绍了在 C++ 中检测一个或两个的补码架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 C++ 中检测架构是使用一补码还是二补码表示的最可靠方法是什么?

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 :)

但最简单的方法可能是将-1"与 ~0 进行比较.

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

这篇关于在 C++ 中检测一个或两个的补码架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆