C++中 integer 是啥意思
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C++中 integer 是啥意思相关的知识,希望对你有一定的参考价值。
integer是整数,整型的意思。整数(integers)就是像-3,-2,-1,0,1,2,3等这样的数。
整数的全体构成整数集,整数集是一个数环。在整数系中,零和正整数统称为自然数。-1、-2、-3、…、-n、…(n为非零自然数)为负整数。则正整数、零与负整数构成整数系。
C++这个词在中国大陆的程序员圈子中通常被读做“C加加”,而西方的程序员通常读做“C plus plus”,“CPP”。 它是一种使用非常广泛的计算机编程语言。C++是一种静态数据类型检查的、支持多重编程范式的通用程序设计语言。它支持过程化程序设计、数据抽象、面向对象程序设计、泛型程序设计等多种程序设计风格。
参考技术A ,有时候也称为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写的)。
====
[原创回答团] 参考技术B integer是整型的意思,但是C++里没有这个数据类型,只有int型,在java里有integer,Integer 是一个类,是对象类型 int是原始类型。本回答被提问者采纳 参考技术C integer英文意思“整数”
pascal,java,VB等等编程软件都把integer作数据类型
c++里的整型数据类型不是integer,是其缩写int。
实际编程时基本不会出现integer 参考技术D 简单说来就是 int 的别名,再深层次个人觉得没太大必要知道
以上是关于C++中 integer 是啥意思的主要内容,如果未能解决你的问题,请参考以下文章