C++中 integer 是什么意思
2015-12-02 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
展开全部
,有时候也称为primitive types)完整的定义(节录自C++03标准):
3.9.1 Fundamental types [basic.fundamental]
1 Objects declared as characters (char) shall be large enough to store any member of the implementation’s
basic character set. If a character from this set is stored in a character object, the integral value of that character
object is equal to the value of the single character literal form of that character. It is implementationdefined
whether a char object can hold negative values. Characters can be explicitly declared unsigned
or signed. Plain char, signed char, and unsigned char are three distinct types. A char, a
signed char, and an unsigned char occupy the same amount of storage and have the same alignment
requirements (3.9); that is, they have the same object representation. For character types, all bits of
the object representation participate in the value representation. For unsigned character types, all possible
bit patterns of the value representation represent numbers. These requirements do not hold for other types.
In any particular implementation, a plain char object can take on either the same values as a
signed char or an unsigned char; which one is implementation-defined.
2 There are four signed integer types: “signed char”, “short int”, “int”, and “long int.” In this
list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural
size suggested by the architecture of the execution environment39) ; the other signed integer types are provided to meet special needs.
3 For each of the signed integer types, there exists a corresponding (but different) unsigned integer type:
“unsigned char”, “unsigned short int”, “unsigned int”, and “unsigned long
int,” each of which occupies the same amount of storage and has the same alignment requirements (3.9)
as the corresponding signed integer type40) ; that is, each signed integer type has the same object representation
as its corresponding unsigned integer type. The range of nonnegative values of a signed integer type
is a subrange of the corresponding unsigned integer type, and the value representation of each corresponding
signed/unsigned type shall be the same.
4 Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2n where n is the number
of bits in the value representation of that particular size of integer.41)
5 Type wchar_t is a distinct type whose values can represent distinct codes for all members of the largest
extended character set specified among the supported locales (22.1.1). Type wchar_t shall have the same
size, signedness, and alignment requirements (3.9) as one of the other integral types, called its underlying
type.
6 Values of type bool are either true or false.42) [Note: there are no signed, unsigned, short, or
long bool types or values. ] As described below, bool values behave as integral types. Values of type
bool participate in integral promotions (4.5).
7 Types bool, char, wchar_t, and the signed and unsigned integer types are collectively called integral
types.43) A synonym for integral type is integer type. The representations of integral types shall define values
by use of a pure binary numeration system.44) [Example: this International Standard permits 2’s complement,
1’s complement and signed magnitude representations for integral types. ]
8 There are three floating point types: float, double, and long double. The type double provides
at least as much precision as float, and the type long double provides at least as much precision as
double. The set of values of the type float is a subset of the set of values of the type double; the set
of values of the type double is a subset of the set of values of the type long double. The value representation
of floating-point types is implementation-defined. Integral and floating types are collectively
called arithmetic types. Specializations of the standard template numeric_limits (18.2) shall specify
the maximum and minimum values of each arithmetic type for an implementation.
9 The void type has an empty set of values. The void type is an incomplete type that cannot be completed.
It is used as the return type for functions that do not return a value. Any expression can be explicitly converted
to type cv void (5.4). An expression of type void shall be used only as an expression statement
(6.2), as an operand of a comma expression (5.18), as a second or third operand of ?: (5.16), as the operand
of typeid, or as the expression in a return statement (6.6.3) for a function with the return type void.
10 [Note: even if the implementation defines two or more basic types to have the same value representation,
they are nevertheless different types. ]
概括而言,C++的对象基本类型包括整数类型(其中又包括字符类型(char和wchar_t)、常规的整数类型(singned和unsigned的int、char、short、long、long long)、bool类型)、浮点数类型(float、double和long double)和void类型。标准定义了编译器实现它们的对象的内置操作时必需满足的特征。对于int、double这类数值类型的操作的具体实现,编译器一般只是把源代码编译成对应平台上的机器(例如CPU或GPU)指令,而指令内部的操作方法由硬件实现(对于现代数字式通用电子计算机而言,是二值数字逻辑电路计算一定的逻辑表达式,然后按约定的格式(例如IEEE-754浮点数规范中定义的)进行输出,具体内容可以参考计算机组成原理和编译原理等相关课程),在C++语言级别上没有源代码;不过对于一些机器指令不直接支持的计算,编译器可以用软件方法实现(例如32位平台的long long运算,无FPU机器的浮点计算),这里的源码就是编译器对应部分的源码(是平台相关的,可能是汇编的,也可能是高级语言——例如C写的)。
====
[原创回答团]
3.9.1 Fundamental types [basic.fundamental]
1 Objects declared as characters (char) shall be large enough to store any member of the implementation’s
basic character set. If a character from this set is stored in a character object, the integral value of that character
object is equal to the value of the single character literal form of that character. It is implementationdefined
whether a char object can hold negative values. Characters can be explicitly declared unsigned
or signed. Plain char, signed char, and unsigned char are three distinct types. A char, a
signed char, and an unsigned char occupy the same amount of storage and have the same alignment
requirements (3.9); that is, they have the same object representation. For character types, all bits of
the object representation participate in the value representation. For unsigned character types, all possible
bit patterns of the value representation represent numbers. These requirements do not hold for other types.
In any particular implementation, a plain char object can take on either the same values as a
signed char or an unsigned char; which one is implementation-defined.
2 There are four signed integer types: “signed char”, “short int”, “int”, and “long int.” In this
list, each type provides at least as much storage as those preceding it in the list. Plain ints have the natural
size suggested by the architecture of the execution environment39) ; the other signed integer types are provided to meet special needs.
3 For each of the signed integer types, there exists a corresponding (but different) unsigned integer type:
“unsigned char”, “unsigned short int”, “unsigned int”, and “unsigned long
int,” each of which occupies the same amount of storage and has the same alignment requirements (3.9)
as the corresponding signed integer type40) ; that is, each signed integer type has the same object representation
as its corresponding unsigned integer type. The range of nonnegative values of a signed integer type
is a subrange of the corresponding unsigned integer type, and the value representation of each corresponding
signed/unsigned type shall be the same.
4 Unsigned integers, declared unsigned, shall obey the laws of arithmetic modulo 2n where n is the number
of bits in the value representation of that particular size of integer.41)
5 Type wchar_t is a distinct type whose values can represent distinct codes for all members of the largest
extended character set specified among the supported locales (22.1.1). Type wchar_t shall have the same
size, signedness, and alignment requirements (3.9) as one of the other integral types, called its underlying
type.
6 Values of type bool are either true or false.42) [Note: there are no signed, unsigned, short, or
long bool types or values. ] As described below, bool values behave as integral types. Values of type
bool participate in integral promotions (4.5).
7 Types bool, char, wchar_t, and the signed and unsigned integer types are collectively called integral
types.43) A synonym for integral type is integer type. The representations of integral types shall define values
by use of a pure binary numeration system.44) [Example: this International Standard permits 2’s complement,
1’s complement and signed magnitude representations for integral types. ]
8 There are three floating point types: float, double, and long double. The type double provides
at least as much precision as float, and the type long double provides at least as much precision as
double. The set of values of the type float is a subset of the set of values of the type double; the set
of values of the type double is a subset of the set of values of the type long double. The value representation
of floating-point types is implementation-defined. Integral and floating types are collectively
called arithmetic types. Specializations of the standard template numeric_limits (18.2) shall specify
the maximum and minimum values of each arithmetic type for an implementation.
9 The void type has an empty set of values. The void type is an incomplete type that cannot be completed.
It is used as the return type for functions that do not return a value. Any expression can be explicitly converted
to type cv void (5.4). An expression of type void shall be used only as an expression statement
(6.2), as an operand of a comma expression (5.18), as a second or third operand of ?: (5.16), as the operand
of typeid, or as the expression in a return statement (6.6.3) for a function with the return type void.
10 [Note: even if the implementation defines two or more basic types to have the same value representation,
they are nevertheless different types. ]
概括而言,C++的对象基本类型包括整数类型(其中又包括字符类型(char和wchar_t)、常规的整数类型(singned和unsigned的int、char、short、long、long long)、bool类型)、浮点数类型(float、double和long double)和void类型。标准定义了编译器实现它们的对象的内置操作时必需满足的特征。对于int、double这类数值类型的操作的具体实现,编译器一般只是把源代码编译成对应平台上的机器(例如CPU或GPU)指令,而指令内部的操作方法由硬件实现(对于现代数字式通用电子计算机而言,是二值数字逻辑电路计算一定的逻辑表达式,然后按约定的格式(例如IEEE-754浮点数规范中定义的)进行输出,具体内容可以参考计算机组成原理和编译原理等相关课程),在C++语言级别上没有源代码;不过对于一些机器指令不直接支持的计算,编译器可以用软件方法实现(例如32位平台的long long运算,无FPU机器的浮点计算),这里的源码就是编译器对应部分的源码(是平台相关的,可能是汇编的,也可能是高级语言——例如C写的)。
====
[原创回答团]
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
integer是整型的意思,但是C++里没有这个数据类型,只有int型,在java里有integer,Integer 是一个类,是对象类型 int是原始类型。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
integer英文意思“整数”
pascal,java,VB等等编程软件都把integer作数据类型
c++里的整型数据类型不是integer,是其缩写int。
实际编程时基本不会出现integer
pascal,java,VB等等编程软件都把integer作数据类型
c++里的整型数据类型不是integer,是其缩写int。
实际编程时基本不会出现integer
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
简单说来就是 int 的别名,再深层次个人觉得没太大必要知道
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询