无符号负图元? [英] Unsigned negative primitives?

查看:113
本文介绍了无符号负图元?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中,我们可以使原语无符号。但他们总是积极的。还有一种方法,使无符号负变量?我知道单词unsigned意味着无符号,所以也不是一个减号( - )。但我认为C ++必须提供它。

In C++ we can make primitives unsigned. But they are always positive. Is there also a way to make unsigned negative variables? I know the word unsigned means "without sign", so also not a minus (-) sign. But I think C++ must provide it.

推荐答案

否。 unsigned 只能包含非负数。

No. unsigned can only contain nonnegative numbers.

如果您需要一个只代表负数的类型,

If you need a type that only represent negative numbers, you need to write a class yourself, or just interpret the value as negative in your program.

(但为什么你需要这样的类型?)

(But why do you need such a type?)

这篇关于无符号负图元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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