转msdn上的Data Type Ranges

本文介绍了Microsoft Visual C++中各种数据类型的字节大小、别名及取值范围,包括整型、字符型、浮点型等基本类型及其变种。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Data Type Ranges

Microsoft Visual C++ recognizes the types shown in the table below.

Type NameBytesOther NamesRange of Values
int*signed,
signed int
System dependent
unsigned int*unsignedSystem dependent
__int81char,
signed char
–128 to 127
__int162short,
short int,
signed short int
–32,768 to 32,767
__int324signed,
signed int
–2,147,483,648 to 2,147,483,647
__int648none–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
bool1nonefalse or true
char1signed char–128 to 127
unsigned char1none0 to 255
short2short int,
signed short int
–32,768 to 32,767
unsigned short2unsigned short int0 to 65,535
long4long int,
signed long int
–2,147,483,648 to 2,147,483,647
long long8none (but equivalent to __int64)–9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
unsigned long4unsigned long int0 to 4,294,967,295
enum*noneSame as int
float4none3.4E +/- 38 (7 digits)
double8none1.7E +/- 308 (15 digits)
long doublesame as doublenonesame as double
wchar_t2__wchar_t0 to 65,535

A variable of __wchar_t designates a wide-character or multibyte character type. By default wchar_t is a typedef for unsigned short. Use the L prefix before a character or string constant to designate the wide-character-type constant. When compiling with /Zc:wchar_t or /Za, the compiler can distinguish between an unsigned short and wchar_t for function overload purposes.

Signed and unsigned are modifiers that can be used with any integral type except bool. The char type is signed by default, but you can specify /J (compiler option) to make it unsigned by default.

The int and unsigned int types have the size of the system word: four bytes. However, portable code should not depend on the size of int.

Microsoft C/C++ also features support for sized integer types. See __int8, __int16, __int32, __int64 for more information. Also see Integer Limits.

See Fundamental Types for more information on the restrictions of the sizes of each type.

See Also

C++ Keywords | Fundamental Types

 

Navigation

 Data Type Ranges
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值