“无符号”关键词 [英] The "unsigned" keyword

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

问题描述

我在一些C ++代码中看到以下形式的关键字unsigned:

  const int HASH_MASK = unsigned 1)> 1; 

及更高版本:

  unsigned hash = HASH_SEED; 

(取自Stanford的CS106B / X阅读器 - 作者:Eric S. Roberts - on



有人可以告诉我这个关键字是什么意思,我什么时候使用它? p>

谢谢!

解决方案

查看: http://stackoverflow.com/a/7176690/1758762


unsigned是一个可以应用于任何整数类型(char,
short,int,long等)的修饰符,但是它本身与无符号
int相同。



I saw in some C++ code the keyword "unsigned" in the following form:

const int HASH_MASK = unsigned(-1) >> 1;

and later:

unsigned hash = HASH_SEED;

(it is taken from the CS106B/X reader - of Stanford - by Eric S. Roberts - on the topic of "implementation of the hash code function for strings").

Can someone tell me please what does that keyword mean and when do I use it anyway?

Thanks!

解决方案

Take a look: http://stackoverflow.com/a/7176690/1758762

unsigned is a modifier which can apply to any integral type (char, short, int, long, etc.) but on its own it is identical to unsigned int.

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

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