简体   繁体   English

是否将“ unsigned int”视为数据类型?

[英]Is “unsigned int” considered to be a data type?

If I have: 如果我有:

unsigned int i;

Is unsigned int considered to be a data type by itself just like an int or a float is a data type? 是否将unsigned int本身视为数据类型,就像intfloat是数据类型一样? or we just say that int is the data type while the unsigned is just modifying the way the data type works? 或者我们只是说int是数据类型,而unsigned只是在修改数据类型的工作方式?

C++ standard §3.9.1, paragraphs 2-3: (C is similar) C ++标准§3.9.1,第2-3段:(C相似)

  1. There are five standard signed integer types : “signed char”, “short int”, “int”, “long int”, and “long long int”… 有五种标准的有符号整数类型:“有符号字符”,“ short int”,“ int”,“ long int”和“ long long int”…
  2. For each of the standard signed integer types, there exists a corresponding (but different) standard unsigned integer type: “unsigned char”, “unsigned short int”, “unsigned int”, “unsigned long int”, and “unsigned long long int”… 对于每种标准有符号整数类型,都有一个对应的(但不同的)标准无符号整数类型:“ unsigned char”,“ unsigned short int”,“ unsigned int”,“ unsigned long int”和“ unsigned long long int” ”…

Yes. 是。 From C11 6.2.5 Types, paragraph 6: 根据C11 6.2.5类型第6段:

For each of the signed integer types, there is a corresponding (but different) unsigned integer type (designated with the keyword unsigned) that uses the same amount of storage (including sign information) and has the same alignment requirements. 对于每个有符号整数类型,都有一个对应的(但不同的)无符号整数类型(用关键字unsigned表示)使用相同的存储量(包括符号信息)并且具有相同的对齐要求。 The type _Bool and the unsigned integer types that correspond to the standard signed integer types are the standard unsigned integer types. _Bool类型和与标准有符号整数类型相对应的无符号整数类型是标准无符号整数类型。 The unsigned integer types that correspond to the extended signed integer types are the extended unsigned integer types. 与扩展的有符号整数类型相对应的无符号整数类型是扩展的无符号整数类型。 The standard and extended unsigned integer types are collectively called unsigned integer types. 标准和扩展的无符号整数类型统称为无符号整数类型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM