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

查看:70
本文介绍了在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天全站免登陆