C Standard Library |
---|
|
In the C programming language, data types refers to an extensive system for declaring variables of different types. The language itself provides basic arithmetic types and syntax to build array and compound types. Several headers in the standard library contain definitions of support types, that have additional properties, such as exact size, guaranteed.[1][2]
Contents |
The C language provides a lot of basic types. Most of them are formed from one of the four basic arithmetic type identifiers in C (char
, int
, float
and double
), and optional specifiers (signed
, unsigned
, short
, long
). All available basic arithmetic types are listed below:
Type | Explanation | Type | Explanation |
---|---|---|---|
Unknown extension tag "source" | smallest addressable unit of the machine that can contain basic character set. It is an integer type. Actual type can be either signed or unsigned depending on implementation | Unknown extension tag "source" | same as char , but guaranteed to be signed. |
Unknown extension tag "source" | same as char , but guaranteed to be unsigned. |
||
Unknown extension tag "source" Unknown extension tag "source" Unknown extension tag "source" Unknown extension tag "source" |
short signed integer type. At least 16 bits in size. | Unknown extension tag "source" Unknown extension tag "source" |
same as short , but unsigned. |
Unknown extension tag "source" Unknown extension tag "source" |
basic signed integer type. At least 16 bits in size. | Unknown extension tag "source" Unknown extension tag "source" |
same as int , but unsigned. |
Unknown extension tag "source" Unknown extension tag "source" Unknown extension tag "source" Unknown extension tag "source" |
long signed integer type. At least 32 bits in size. | Unknown extension tag "source" Unknown extension tag "source" |
same as long , but unsigned. |
Unknown extension tag "source" Unknown extension tag "source" Unknown extension tag "source" Unknown extension tag "source" |
long long signed integer type. At least 64 bits in size. Specified since the C99 version of the standard. | Unknown extension tag "source" Unknown extension tag "source" |
same as long long , but unsigned. Specified only in C99 version of the standard. |
Unknown extension tag "source" | (single precision) floating-point type. Actual properties unspecified, however on most systems this is IEEE 754 single precision floating point format. | ||
Unknown extension tag "source" | double precision floating-point type. Actual properties unspecified, however on most systems this is IEEE 754 double precision floating point format. | ||
Unknown extension tag "source" | extended precision floating-point type. Actual properties unspecified. On most systems this is equivalent either to Unknown extension tag "source", 80-bit floating point format, or IEEE 754 quadruple precision floating-point format. |
The actual size of integer types varies by implementation. The only guarantee is that the long long
is not smaller than long
, which is not smaller than int
, which is not smaller than short
. Also, int
should be the integer type that the target processor is most efficient working with. This allows great flexibility: for example, all types can be 64-bit. However, only several different integer width schemes (data models) are popular and since data model defines how different programs communicate, a uniform data model is used within a given operating system application interface.[3]
The actual size of floating point types also varies by implementation. The only guarantee is that the long double
is not smaller than double
, which is not smaller than float
. Usually, 32-bit and 64-bit IEEE 754 floating point formats are used, if supported by hardware.
The C language did not have a boolean type until the C99 version of the standard. In C99 the boolean type has been added as _Bool
. Additionally, a new header stdbool.h
has been added for compatibility reasons. This header allows programmers to use boolean types in the same way as in the C++ language. The missing identifiers are defined as macros: bool
is defined as _Bool
, true
as 1, false
as 0. Additionally, __bool_true_false_are_defined
is defined as 1.
The C language provides the separate types size_t
and ptrdiff_t
to represent memory-related quantities. Existing types were deemed insufficient, because their size is defined according to the target processor's arithmetic capabilities, not the memory capabilities, such as available address space. Both of these types are defined in the stddef.h
header (cstddef
header in C++).
size_t
is used to represent the maximum size of any object (including arrays) in the particular implementation. It is used as the return type of the sizeof
operator. The maximum size of size_t
is provided via SIZE_MAX
, a macro constant which is defined in the stdint.h
header (cstdint
header in C++). It is guaranteed to be at least 65535.
ptrdiff_t
is used to represent the difference between pointers.
Information about the actual properties, such as size, of the basic arithmetic types, is provided via macro constants in two headers: limits.h
header (climits
header in C++) defines macros for integer types and float.h
header (cfloat
header in C++) defines macros for floating-point types. The actual values depend on the implementation.
CHAR_BIT
- size of the Unknown extension tag "source" type in bits (it is not necessarily 8 bits)SCHAR_MIN
, SHRT_MIN
, INT_MIN
, LONG_MIN
, LLONG_MIN
(C99) - minimum possible value of signed integer types: Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source"SCHAR_MAX
, SHRT_MAX
, INT_MAX
, LONG_MAX
, LLONG_MAX
(C99) - maximum possible value of signed integer types: Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source"UCHAR_MAX
, USHRT_MAX
, UINT_MAX
, ULONG_MAX
, ULLONG_MAX
(C99) - maximum possible value of unsigned integer types: Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source"CHAR_MIN
- minimum possible value of Unknown extension tag "source"CHAR_MAX
- maximum possible value of Unknown extension tag "source"MB_LEN_MAX
- maximum number of bytes in a multibyte characterFLT_MIN
, DBL_MIN
, LDBL_MIN
- minimum value of Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_MAX
, DBL_MAX
, LDBL_MAX
- maximum value of Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_ROUNDS
- rounding mode for floating-point operationsFLT_EVAL_METHOD
- evaluation method of expressions involving different floating-point types (only available in C99)FLT_RADIX
- radix of the exponent in the floating-point typesFLT_DIG
, DBL_DIG
, LDBL_DIG
- number of decimal digits that can be represented without losing precision by Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_EPSILON
, DBL_EPSILON
, LDBL_EPSILON
- difference between 1.0 and the next representable value of Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_MANT_DIG
, DBL_MANT_DIG
, LDBL_MANT_DIG
- number of FLT_RADIX
-base digits in the floating-point mantissa for types Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_MIN_EXP
, DBL_MIN_EXP
, LDBL_MIN_EXP
- minimum negative integer such that FLT_RADIX
raised to a power one less than that number is a normalized Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_MIN_10_EXP
, DBL_MIN_10_EXP
, LDBL_MIN_10_EXP
- minimum negative integer such that 10 raised to a power one less than that number is a normalized Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_MAX_EXP
, DBL_MAX_EXP
, LDBL_MAX_EXP
- maximum positive integer such that FLT_RADIX
raised to a power one more than that number is a normalized Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyFLT_MAX_10_EXP
, DBL_MAX_10_EXP
, LDBL_MAX_10_EXP
- maximum positive integer such that 10 raised to a power one more than that number is a normalized Unknown extension tag "source", Unknown extension tag "source", Unknown extension tag "source" respectivelyDECIMAL_DIG
- minimum number of decimal digits needed to represent all the significant digits for Unknown extension tag "source".[4] The value is at least 10. (only available in C99)The C99 standard includes definitions of several new integer types to enhance the portability of programs[2]. The already available basic integer types were deemed insufficient, because their actual sizes are implementation defined and may vary across different systems. The new types are especially useful in embedded environments where hardware supports usually only several types and that support varies from system to system. All new types are defined in inttypes.h
header (cinttypes
header in C++) and also are available at stdint.h
header (cstdint
header in C++). The types can be grouped into the following categories:
The following table summarizes the types and the interface to acquire the implementation details (N refers to the number of bits):
Type category | Signed types | Unsigned types | ||||
---|---|---|---|---|---|---|
Type | Minimum value | Maximum value | Type | Minimum value | Maximum value | |
Exact width | intN_t |
INTN_MIN |
INTN_MAX |
uintN_t |
0 | UINTN_MAX |
Least width | int_leastN_t |
INT_LEASTN_MIN |
INT_LEASTN_MAX |
uint_leastN_t |
0 | UINT_LEASTN_MAX |
Fastest | int_fastN_t |
INT_FASTN_MIN |
INT_FASTN_MAX |
uint_fastN_t |
0 | UINT_FASTN_MAX |
Pointer | intptr_t |
INTPTR_MIN |
INTPTR_MAX |
uintptr_t |
0 | UINTPTR_MAX |
Maximum width | intmax_t |
INTMAX_MIN |
INTMAX_MAX |
uintmax_t |
0 | UINTMAX_MAX |
The inttypes.h
header (cinttypes
header in C++) provides features that enhances the functionality of the types defined in stdint.h
header. The included things are macros that define printf format string and scanf format string specifiers corresponding to the stdint.h
types and several functions for working with intmax_t
and uintmax_t
types. This header is available only in C99 version of the standard.
All defined macros are in the following format: PRI{fmt}{type}
. Here {fmt} defines the output formatting and is one of d
(decimal), x
(hexadecimal), o
(octal), u
(unsigned) and i
(integer). {type} defines the type of the argument and is one of N
, FASTN
, LEASTN
, PTR
, MAX
, where N
corresponds to the number of bits in the argument.
All defined macros are in the following format: SCN{fmt}{type}
. Here {fmt} defines the output formatting and is one of d
(decimal), x
(hexadecimal), o
(octal), u
(unsigned) and i
(integer). {type} defines the type of the argument and is one of N
, FASTN
, LEASTN
, PTR
, MAX
, where N
corresponds to the number of bits in the argument.
![]() |
This section requires expansion. |
Structures are a way of storing multiple pieces of data in one variable. For example, say we wanted to store the name and birthday of a person in strings, in one variable. We could use a structure to house that data:
<source lang="c"> struct birthday {
char name[20]; int day; int month; int year;
}; </source>
Structures may contain pointers to structs of its own type, which is common in linked datastructures.
A C implementation has freedom to design the memory layout of the struct, with few restrictions; one being that the memory address of the first member will be the same as the address of struct itself. Structs may be initialized or assigned to using compound literals.
For every type T, except void and function types, there exist the types “array of N elements of type T”.
An array is a collection of values, all of the same type, stored contiguously in memory. An array of size N is indexed by integers from 0 up to and including N-1.
For example: <source lang="c"> int cat[10]; </source>
Arrays can be initialized with a compound initializer, but not assigned. Arrays are passed to functions by passing a pointer to the first element.
For every type T there exists a type “pointer to T”.
Variables can be declared as being pointers to values of various types, by means of the *
type declarator. To declare a variable as a pointer, precede its name with an asterisk. <source lang="c"> char *square; long *circle; </source>
Union types are special structures which allow access to the same memory using different type descriptions; one could, for example, describe a union of data types which would allow reading the same data as an integer, a float or a user declared type: <source lang="c"> union {
int i; float f; struct { unsigned int u; double d; } s;
} u; </source> In the above example the total size of u
is the size of u.s
(which is the sum of the sizes of u.s.u
and u.s.d
), since s is larger than both i
and f
. When assigning something to u.i
, some parts of u.f
may be preserved if u.i
is smaller than u.f
.
Reading from a union member is not the same as casting since the value of the member is not converted, but merely read.
Function pointers allow referencing functions with a particular signature. For example, to store the address of the standard function abs
in the variable my_int_f
:
<source lang="c"> int (*my_int_f)(int) = abs; </source>
Function pointers are invoked by name just like normal function calls. Function pointers are separate from pointers and void pointers.
![]() |
The Wikibook C Programming has a page on the topic of |
|
Double-precision floating-point format is a computer number format that occupies 8 bytes (64 bits) in computer memory and represents a wide, dynamic range of values by using a floating point.
Double-precision floating-point format usually refers to binary64, as specified by the IEEE 754 standard, not to the 64-bit decimal format decimal64.
Double-precision binary floating-point is a commonly used format on PCs, due to its wider range over single-precision floating point, in spite of its performance and bandwidth cost. As with single-precision floating-point format, it lacks precision on integer numbers when compared with an integer format of the same size. It is commonly known simply as double. The IEEE 754 standard specifies a binary64 as having:
This gives 15–17 significant decimal digits precision. If a decimal string with at most 15 significant digits is converted to IEEE 754 double precision representation and then converted back to a string with the same number of significant digits, then the final string should match the original. If an IEEE 754 double precision is converted to a decimal string with at least 17 significant digits and then converted back to double, then the final number must match the original.
A double occurs in volleyball when a player, during a match, is credited with scoring at least ten times in one (or more) of five statistical categories: Aces, Kills, Blocks, Digs, and Assists. The term was apparently derived from similar basketball jargon; the expression "triple-double" was coined by former Los Angeles Lakers public relations director Bruce Jolesch in order to showcase Magic Johnson's versatility.
There are four main types of doubles:
Of the five statistical categories, double digit match totals are most common for assists, but rare for any positions other than setter. The next most frequent double-digit category is digs, which is most often attained by liberos or defensive specialists, but can be achieved by any strong defensive player. Kills are the third most common double-digit achievement category, occurring predominantly among hitters, especially outside hitters and middle blockers. Likewise, double-digit blocking numbers are preponderantly accomplished by middle blockers or outside hitters, but are much less common than double-digit kills. Rarest by far are double-digit aces, which even the most exceptional server is unlikely to attain once in a career.
The abbreviation SWS represents, among other things,
SWS is a hybrid trolleybus prototype that was developed and produced by three Finnish companies Suomen Autoteollisuus (SAT), Wiima and Strömberg in 1979.
The Helsinki City Transport (HKL) ordered the prototype to gain experience for the future public transportation strategy for city of Helsinki. The trolleybus got its power from the overhead wires, but for wireless parts it had a diesel generator as a power source. The prototype contained advanced technology.
The SWS prototype participated in COST 303 project in 1985 among other corresponding prototypes. As a part of the project, SWS was shipped to Belgium, where it served for half year in city of Ghent.
Eventually, trolleybus transport was seen too expensive compared to the conventional diesel option, and therefore the City of Helsinki decided to discontinue the trolleybus service and replace it by diesel buses. The SWS trolleybus was kept for possible further investigation.
In 1970 the Helsinki City Transport (HKL) suggested the city council to give up with trolleybus transportation. Instead, the council suggested the city board to extend the trolleybus network. The city transport committee calculated that the planned extensions would demand 70 vehicles. Based on the quotations HKL got, they decided to lease for trials Soviet made ZiU trolleybuses, for which they had got the cheapest offer. The vehicles arrived in February 1973 and they were taken to Wiima factory for converting them to meet the Finnish requirements. The test transportation began in May and continued until November, when the trolleybuses were returned to Soviet Union by rail.
"Mirrors" is a song by the English recording artist Natalia Kills from her debut studio album, Perfectionist (2011). It was released by Cherrytree Records on 10 August 2010 as the lead single from the album. The track was written and produced by Akon, Giorgio Tuinfort and Martin "Cherry Cherry Boom Boom" Kierszenbaum, with additional writing from Kills. Described as a "disco pop" song, "Mirrors" contains references to various themes including sexual sadomasochism and arrogance.
Critical response to "Mirrors" was generally positive—most music critics denoted it as a standout from Perfectionist. The track received chart success in some countries of Europe, reaching the top ten of Austria, Germany, and Poland. On the US Hot Dance Club Songs, it peaked at number three, whereas in the United Kingdom, it failed to reach the top 100. The music video for "Mirrors" was directed by Guillaume Doubet, and follows Kills exploring the concepts of vanity, control and sex after being mysteriously dragged into a mirror. She further promoted the song with live performances on the 2011 Life Ball and on the German programme Schlag den Raab.
Mirrors is the sixth studio album by Blue Öyster Cult, released in 1979. Mirrors is the first Blue Öyster Cult album not produced by long-time producer and manager Sandy Pearlman. The album is notable for a collaboration with British fantasy/science-fiction author Michael Moorcock who co-wrote a song based on his novel The Fireclown. "The Great Sun Jester" is the first of several Moorcock co-writing credits with the band.
After the success of 1976's Platinum Agents of Fortune, 1977's Gold Spectres and 1978's Platinum live effort Some Enchanted Evening, the fact that Mirrors struggled to reach Gold status was disappointing to band and label alike. According to interviews with the band and the production staff, the intent for this album was to make a high charting and glossy production; however the backlash felt from this attempt was a reason for their future pairing with Martin Birch, and their attempt to return to a darker sound.
"In Thee" was written by Allen Lanier. It went in to the chart at No. 74. A live version is featured on their 1998 album Heaven Forbid, it features two acoustic guitars and was a popular "in concert" moment from this era. The line "Jim says some destinies should not be delivered" references the Jim Carroll Band song "Day and Night."