المتغيرات
فضاءات التسمية
أفعال

الأنواع الأساسية

من cppreference.com
< cpp‏ | language


انظر هنا لرؤية الأنواع الأخرى التي تدعمها لغة مكتبات C++.

محتويات

[تعديل]النوع المنطقي boolean :

النوع - bool : يعيد قيمتين لاغير هما إما true or false أي صح أو خطأ

[تعديل]النوع الحرفي Character :

signedchar - نوع حرفي يتأثر بالإشارة
unsignedchar - نوع حرفي لايتأثر بالأشارة فقط الأعداد الموجبة
char - هذا النوع يمثل النوع الحرفي الأساسية يمكنه التعامل مع الحروف بأكثر فعالية أي (يكافئ الإثنين معا signedchar or unsignedchar).
wchar_t - type for wide character representation
char16_t - type for UTF-16 character representation (since C++11)
char32_t - type for UTF-32 character representation (since C++11)

[تعديل] النوع العددي Integer :

int - basic integer type. Can be omitted if any of the modifiers are present. If no length modifiers are present, guaranteed to have width of at least 16 bits. However, on 32/64 bit systems it is almost exclusively guaranteed to have width of at least 32 bits (see below).

[تعديل]التعديلات :

يمكنك تعديل الانواع العددية فيمكنك جعلها لاتقبل إلا الأعداد الموجبة أو السالبة .

Signedness

signed - target type will have signed representation (this is the default if omitted)
unsigned - target type will have unsigned representation

Size

short - target type will be optimized for space and will have width of at least 16 bits.
long - target type will have width of at least 32 bits.
longlong - target type will have width of at least 64 bits (since C++11)

[تعديل]الخصائص :

The following table summarizes all available integer types and their properties:

Type specifier Equivalent type Width in bits by data model
C++ standard LP32 ILP32 LLP64 LP64
short
shortint at least
16
16161616
shortint
signedshort
signedshortint
unsignedshort
unsignedshortint
unsignedshortint
int
int at least
16
16323232
signed
signedint
unsigned
unsignedint
unsignedint
long
longint at least
32
32323264
longint
signedlong
signedlongint
unsignedlong
unsignedlongint
unsignedlongint
longlong
longlongint
(C++11)
at least
64
64646464
longlongint
signedlonglong
signedlonglongint
unsignedlonglong
unsignedlonglongint
(C++11)
unsignedlonglongint

Note: the C++ Standard guarantees that 1== sizeof(char)<= sizeof(short)<= sizeof(int)<= sizeof(long)<= sizeof(longlong).

[تعديل]Data models

32 bit systems:

  • LP32:
  • Win16 API
  • ILP32;
  • Win32 API
  • Unix and Unix-like systems (Linux, Mac OS X)

64 bit systems:

  • LLP64
  • Win64 API
  • LP64
  • Unix and Unix-like systems (Linux, Mac OS X)

[تعديل]Floating point types

float - single precision floating point type. Usually IEEE-754 32 bit floating point type
double - double precision floating point type. Usually IEEE-754 64 bit floating point type
longdouble - extended precision floating point type. Does not necessarily map to types mandated by IEEE-754. Usually 80-bit x87 floating point type on x86 and x86-64 architectures.

[تعديل]المدى المسحموح به للقيم :

The following table provides a reference for limits of common numeric representations. Note, that all popular data models (including all of ILP32, LP32, LP64, LLP64) use two's complement arithmetic. Also, the C++ Standard does not specify which arithmetic would be used, thus it guarantees only the limits of one's complement arithmetic.

Type Size in bits Format Value range
Approximate Exact
character 8 signed (one's complement)-127 to 127
signed (two's complement)-128 to 127
unsigned 0 to 255
integral 16 signed (one's complement)± 3.27 · 104-32767 to 32767
signed (two's complement)-32768 to 32767
unsigned 0 to 6.55 · 1040 to 65535
32 signed (one's complement)± 2.14 · 109-2,147,483,647 to 2,147,483,647
signed (two's complement)-2,147,483,648 to 2,147,483,647
unsigned 0 to 4.29 · 1090 to 4,294,967,295
64 signed (one's complement)± 9.22 · 1018-9,223,372,036,854,775,807 to 9,223,372,036,854,775,807
signed (two's complement)-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
unsigned 0 to 1.84 · 10190 to 18,446,744,073,709,551,615
floating
point
32 IEEE-754± 3.4 · 10± 38
(~7 digits)
  • min subnormal: ± 1.401,298,4 · 10-47
  • min normal: ± 1.175,494,3 · 10-38
  • max: ± 3.402,823,4 · 1038
64 IEEE-754 ± 1.7 · 10± 308
(~15 digits)
  • min subnormal: ± 4.940,656,458,412 · 10-324
  • min normal: ± 2.225,073,858,507,201,4 · 10-308
  • max: ± 1.797,693,134,862,315,7 · 10308

[تعديل]الكلمات المحجوزة

قالب:منطفي, قالب:صح, قالب:خطأ, قالب:حرفي, قالب:حرفي موجب, char16_t, char32_t, قالب:عددي, قالب:قصير, قالب:طويل, قالب:إشارة, قالب:بدون إشارة, قالب:عشري, قالب:حقيقي

[تعديل]إنظر أيضا

close