Which is a type of long
(See also type for type system overview and the list of type-related utilities that are provided by the C++ library) Show
Contents
[edit] Void typevoid - type with an empty set of values. It is an incomplete type that cannot be completed (consequently, objects of typevoid are disallowed). There are no arrays of void , nor references to void . However, pointers to void and
functions returning type void (procedures in other languages) are permitted. [edit] std::nullptr_t
std::nullptr_t is the type of the null pointer literal, sizeof(std::nullptr_t) is equal to sizeof(void *). [edit] Data modelsThe choices made by each implementation about the sizes of the fundamental types are collectively known as data model. Four data models found wide acceptance: 32 bit systems:
64 bit systems:
Other models are very rare. For example, ILP64 (8/8/8: [edit] Signed and unsigned integer typesint - basic integer type. The keywordint may be omitted if any of the modifiers listed below are used. If no length modifiers are present, it's guaranteed to have a 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). [edit] ModifiersModifies the basic integer type. Can be mixed in any order. Only one of each group can be present in type name. Signedness signed - target type will have signed representation (this is the default if omitted) unsigned - target type will have unsigned representationSize 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.
Note: as with all type specifiers, any order is permitted: unsigned long long int and long int unsigned long name the same type. [edit] PropertiesThe following table summarizes all available integer types and their properties in various common data models:
Note: integer arithmetic is defined differently for the signed and unsigned integer types. See arithmetic operators, in particular integer overflows. std::size_t is the unsigned integer type of the result of the [edit] Boolean typebool - type, capable of holding one of the two values:true or false . The value of sizeof(bool) is implementation defined and might differ from 1. [edit] Character typessigned char - type for signed character representation. unsigned char - type for unsigned character representation. Also used to inspect object representations (raw memory). char - type for character representation which can be most efficiently processed on the target system (has the same representation and alignment as either signed char or unsigned char, but is always a distinct type). Multibyte characters strings use this type to represent code units. For every value of type unsigned char in range [0, 255], converting the value to char and then back to unsigned char produces the original value. (since C++11) The signedness of char depends on the compiler and the target platform: the defaults for ARM and PowerPC are typically unsigned, the defaults for x86 and x64 are typically signed. wchar_t - type for wide character representation (see wide strings). It has the same size, signedness, and alignment as one of the integer types, but is a distinct type. In practice, it is 32 bits and holds UTF-32 on Linux and many other non-Windows systems, but 16 bits and holds UTF-16 code units on Windows. The standard used to require wchar_t to be large enough to represent any supported character code point. However, such requirement cannot be fulfilled on Windows, and thus it is considered as a defect and removed.
Besides the minimal bit counts, the C++ Standard guarantees that 1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long).Note: this allows the extreme case in which bytes are sized 64 bits, all types (including char) are 64 bits wide, and sizeof returns 1 for every type. [edit] Floating-point typesThe following three types and their cv-qualified versions are collectively called floating-point types. float - single precision floating-point type. Matches IEEE-754 binary32 format if supported. double - double precision floating-point type. Matches IEEE-754 binary64 format if supported. long double - extended precision floating-point type. Matches IEEE-754 binary128 format if supported, otherwise matches IEEE-754 binary64-extended format if supported, otherwise matches some non-IEEE-754 extended floating-point format as long as its precision is better than binary64 and range is at least as good as binary64, otherwise matches IEEE-754 binary64 format.
[edit] PropertiesFloating-point types may support special values:
Real floating-point numbers
may be used with arithmetic operators + - / * and various mathematical functions from Floating-point expressions may have greater range and precision than indicated by their types, see FLT_EVAL_METHOD. Floating-point expressions may also be contracted, that is, calculated as if all intermediate values have infinite range and precision, see #pragma STDC FP_CONTRACT. Standard C++ does not restrict the accuracy of floating-point operations. Some operations on floating-point numbers are affected by and modify the state of the floating-point environment (most notably, the rounding direction). Implicit conversions are defined between real floating types and integer types. See Limits of floating-point types and std::numeric_limits for additional details, limits, and properties of the floating-point types. [edit] Range of valuesThe following table provides a reference for the limits of common numeric representations. Prior to C++20, the C++ Standard allowed any signed integer representation, and the minimum guaranteed range of N-bit signed integers was from
-(2N-1 However,
all C++ compilers use two's complement representation, and as of C++20, it is the only representation allowed by the standard, with the guaranteed range from -2N-1 8-bit ones' complement and sign-and-magnitude representations for char have been disallowed since C++11 (via the resolution of CWG issue 1759), because a UTF-8 code unit of value 0x80 used in a UTF-8 string literal must be storable in a char element object.
Note: actual (as opposed to guaranteed minimal) limits on the values representable by these types are available in C numeric limits interface and std::numeric_limits. [edit] Notes
[edit] Keywordsvoid, bool, true, false, char, wchar_t, char8_t, (since C++20) char16_t, char32_t, (since C++11) int, short, long, signed, unsigned, float, double [edit] Defect reportsThe following behavior-changing defect reports were applied retroactively to previously published C++ standards.
[edit] See also
What is type long in C?The long data type stores integers like int , but gives a wider range of values at the cost of taking more memory. Long stores at least 32 bits, giving it a range of -2,147,483,648 to 2,147,483,647. Alternatively, use unsigned long for a range of 0 to 4,294,967,295.
What is long data type example?The long data type is used when you need a range of values more than those provided by int. Example: long a = 100000L, long b = -200000L.
What type is long?long: The long data type is a 64-bit two's complement integer. The signed long has a minimum value of -263 and a maximum value of 263-1. In Java SE 8 and later, you can use the long data type to represent an unsigned 64-bit long, which has a minimum value of 0 and a maximum value of 264-1.
Is long long a datatype?LongLong (LongLong integer) variables are stored as signed 64-bit (8-byte) numbers ranging in value from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. The type-declaration character for LongLong is the caret (^). LongLong is a valid declared type only on 64-bit platforms.
|