m.kelas-karyawan-ftumj.prestasi.web.id Layanan Informasi 17 Jam
Telp/Fax : 021-8762002, 8762003, 8762004, 87912360
HP/SMS : 081 1110 4824 27, 0812 9526 2009, 08523 1234 000
WhatsApp : 0817 0816 486, 0812 9526 2009
email : _Hubungi Kami__ silahkan klik
Chatting dengan Staf :
ggkarir.com
ggiklan.com
Pilih Bahasa :   ID   EN   Permintaan Katalog / Brosur (GRATIS via POS)   Kelas Karyawan   Reguler
D3 Analis KesehatanS1 Ilmu Kesejahteraan SosialS1 Hubungan InternasionalS1 Bahasa Inggris / Sastra InggrisS1 Agroteknologi (Agroindustri, Teknologi Industri Pertanian)TV & Radio IndonesiaSMPTokohMySQLRDBMS (Sistem Database)Debat Agama Hindu

   
Cari  
    Komputer & Telekomunikasi

    Sebelumnya  (bzip2) (C Sharp syntax)  Berikutnya    

C data types

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

Basic types

The C language provides many 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:

TypeExplanationTypeExplanation
charsmallest 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 implementationsigned charsame as char, but guaranteed to be signed.
unsigned charsame as char, but guaranteed to be unsigned.
short
short int
signed short
signed short int
short signed integer type. At least 16 bits in size.unsigned short
unsigned short int
same as short, but unsigned.
int
signed int
basic signed integer type. At least 16 bits in size.unsigned
unsigned int
same as int, but unsigned.
long
long int
signed long
signed long int
long signed integer type. At least 32 bits in size.unsigned long
unsigned long int
same as long, but unsigned.
long long
long long int
signed long long
signed long long int
long long signed integer type. At least 64 bits in size. Specified since the C99 version of the standard.unsigned long long
unsigned long long int
same as long long, but unsigned. Specified only in C99 version of the standard.
float(single precision) floating-point type. Actual properties unspecified, however on most systems this is IEEE 754 single precision floating point format.
doubledouble precision floating-point type. Actual properties unspecified, however on most systems this is IEEE 754 double precision floating point format.
long doubleextended precision floating-point type. Actual properties unspecified. Unlike types float and double, it can be either 80-bit floating point format, the non-IEEE "double-double" or IEEE 754 quadruple precision floating-point format if a higher precision format is provided, otherwise it is the same as double. See this page for details.

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]

In practice it should be noted that char is usually 8 bits in size, short is usually 16 bits in size and long is usually 32 bits in size (likewise unsigned char, unsigned short and unsigned long). For example this holds true for platforms as diverse as 1990s Sun0S 4 Unix, Microsoft MSDOS, modern Linux, and Microchip MCC18 for embedded 8 bit PIC microcontrollers.

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.

Boolean type

The boolean (true/false) type is _Bool. The stdbool.h type also defines a few useful identifiers as macros: bool is defined as _Bool, true as 1, false as 0. Additionally, __bool_true_false_are_defined is defined as 1. The _Bool type and stdbool.h header did not exist in pre-1999 versions of the standard.

Size and pointer difference types

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 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.

Interface to the properties of the basic types

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.

Properties of integer types
  • CHAR_BIT – size of the char type in bits (at least 8 bits)
  • SCHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN(C99) – minimum possible value of signed integer types: signed char, signed short, signed int, signed long, signed long long
  • SCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX(C99) – maximum possible value of signed integer types: signed char, signed short, signed int, signed long, signed long long
  • UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX(C99) – maximum possible value of unsigned integer types: unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long
  • CHAR_MIN – minimum possible value of char
  • CHAR_MAX – maximum possible value of char
  • MB_LEN_MAX – maximum number of bytes in a multibyte character
Properties of floating-point types
  • FLT_MIN, DBL_MIN, LDBL_MIN – minimum value of float, double, long double respectively
  • FLT_MAX, DBL_MAX, LDBL_MAX – maximum value of float, double, long double respectively
  • FLT_ROUNDS – rounding mode for floating-point operations
  • FLT_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 types
  • FLT_DIG, DBL_DIG, LDBL_DIG – number of decimal digits that can be represented without losing precision by float, double, long double respectively
  • FLT_EPSILON, DBL_EPSILON, LDBL_EPSILON – difference between 1.0 and the next representable value of float, double, long double respectively
  • FLT_MANT_DIG, DBL_MANT_DIG, LDBL_MANT_DIG – number of FLT_RADIX-base digits in the floating-point mantissa for types float, double, long double respectively
  • FLT_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 float, double, long double respectively
  • FLT_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 float, double, long double respectively
  • FLT_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 float, double, long double respectively
  • FLT_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 float, double, long double respectively
  • DECIMAL_DIG – minimum number of decimal digits needed to represent all the significant digits for long double.[4] The value is at least 10. (only available in C99)

Fixed width integer types

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:

  • Exact width integer types which are guaranteed to have the same number N of bits across all implementations. Included only if it is available in the implementation.
  • Least width integer types which are guaranteed to be the smallest type available in the implementation, that has at least specified number N of bits. Guaranteed to be specified for at least N=8,16,32,64.
  • Fastest integer types which are guaranteed to be the fastest integer type available in the implementation, that has at least specified number N of bits. Guaranteed to be specified for at least N=8,16,32,64.
  • Pointer integer types which are guaranteed to be able to hold a pointer
  • Maximum width integer types which are guaranteed to be the largest integer type in the implementation

The following table summarizes the types and the interface to acquire the implementation details (N refers to the number of bits):

Type categorySigned typesUnsigned types
TypeMinimum valueMaximum valueTypeMinimum valueMaximum value
Exact widthintN_tINTN_MININTN_MAXuintN_t0UINTN_MAX
Least widthint_leastN_tINT_LEASTN_MININT_LEASTN_MAXuint_leastN_t0UINT_LEASTN_MAX
Fastestint_fastN_tINT_FASTN_MININT_FASTN_MAXuint_fastN_t0UINT_FASTN_MAX
Pointerintptr_tINTPTR_MININTPTR_MAXuintptr_t0UINTPTR_MAX
Maximum widthintmax_tINTMAX_MININTMAX_MAXuintmax_t0UINTMAX_MAX


Printf and scanf format specifiers

The inttypes.h header (cinttypes header in C++) provides features that enhance the functionality of the types defined in stdint.h header. Included 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 was added in C99.

Printf format string

The macros are in the 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.

Scanf format string

The macros are in the 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.

Functions

Structures

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:

struct birthday{    char name[20];    int day;    int month;    int year;};

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.

A user-written function can directly return a structure, though it will often not be very efficient at run-time.

Arrays

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:

int cat[10];

Arrays can be initialized with a compound initializer, but not assigned. Arrays are passed to functions by passing a pointer to the first element.

Pointer types

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.

char *square;long *circle;

Unions

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:

union{    int i;    float f;    struct    {        unsigned int u;        double d;    } s;} u;

In the above example the total size of u is the size of u.s (which happens to be 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

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:

int (*my_int_f)(int) = abs;

Function pointers are invoked by name just like normal function calls. Function pointers are separate from pointers and void pointers.

See also

References

    Sebelumnya  (bzip2) (C Sharp syntax)  Berikutnya    





Tags: C data types, Komputer, Telekomunikasi, 2243, C data types C Standard Library Data types Character classification Strings Mathematics File input/output Date/time Localization Memory allocation Process control Signals Alternative tokens Miscellaneous headers :, lt;assert.h, gt;, lt;errno.h, gt;, lt;setjmp.h, gt;, lt;stdarg.h, gt; In the C programming language data types refers to an extensive system for declaring variables of different types, The, C data types, Bahasa Indonesia, Contoh Instruksi, Tutorial, Referensi, Buku, Petunjuk, S1 kimia, S2 pendidikan bahasa indonesia, D3 manajemen, S2 magister teknik elektro mt, S1 manajemen sumber daya perairan, Perkuliahan s2 puputan, Singokarir, Program d3 bekasi, Singokerja m.kelas karyawan ftumj, prestasi.web.id
 Program Kuliah Paralel    Kumpulan Ilmu Bebas    Program Pascasarjana (Magister, S2)    Permintaan Keringanan Biaya Pendidikan    Program Perkuliahan Reguler Sore/Malam    Download Katalog    Tips & Trik Psikotes    Pendaftaran Online    Beragam Perdebatan    Perkuliahan Blended di 112 PTS Terbaik    Buku Manual    Kelas Tanpa Uang    Bursa Karir
Perkuliahan Reguler (Hybrid)

Koleksi Jenis Foto
Penerimaan Mahasiswa/i
Program Studi
Layanan + Download

Pustaka Khusus
Kumpulan Web Kuliah Karyawan
Kumpulan Web Perkuliahan Reguler Sore/Malam
Kumpulan Web Seluruh PTS
Kumpulan Web Kuliah Reguler
Kumpulan Web Program Magister (Pascasarjana, S2)

 Quran Online    Tips & Trik Psikotes    Bermacam2 Pariwara    Waktu Sholat
Manfaat Kecombrang (Honje)

Vitamin A, Vitamin A, Merawat tanaman / tumbuhan Sawo Kecik, dsb.

Beritahu Rekan
Nama Saya

Email Saya

Email Rekan 1

Email Rekan 2 (tidak wajib)

Email Rekan 3 (tidak wajib)
➪ harus diisi dengan benar

Tautan Khusus
Pendidikan
PTS Tersohor & Terkenal
Penyelenggara Program S1, S2, D3

Tautan Elok
silakan klik
Ensiklopedi Bebas

p2k.staimiftahululum.ac.id  |  stienus.web.id  |  p2k.stienus.ac.id  |  ibisapurworejo.web.id  |  stiedharmanasional.web.id  |  mt-istn.web.id  |  s2-umsurabaya.web.id  |  p2k.nusamandiri.ac.id  |  p2k.cyber-univ.ac.id  |  uin-al-azhaar.web.id  |  unnur.web.id

s1-kimia.prestasi.web.id  ➮   s2-pendidikan-bahasa-indonesia.prestasi.web.id  ➮   d3-manajemen.prestasi.web.id  ➮   s2-magister-teknik-elektro-mt.prestasi.web.id  ➮   s1-manajemen-sumber-daya-perairan.prestasi.web.id
perkuliahan-s2-puputan-p2k-polnas-denpasar.singokarir.com  ➮   program-d3-bekasi-p2k-sttbinatunggal.singokerja.com  ➮   program-kelas-diploma-tiga-kepanjen-p2k-stiki-malang.singomart.com  ➮   program-kuliah-strata-satu-p2k-undaris.singomart.web.id  ➮   program-perkuliahan-strata-dua-jombang-p2k-indocakti.singomusic.info  ➮   beasiswa-strata-tiga-bekasi-p2k-hidayatullah.singomusic.web.id  ➮   program-beasiswa-s3-pendidikan-p2k-unisa.singomusik.com  ➮   kelas-eksekutif-tuminting-p2k-nusantara.singomusik.web.id
utsmakassar.prestasi.web.id  ➮  widyapersada.prestasi.web.id  ➮  uby.prestasi.web.id  ➮  cyberuniversity.prestasi.web.id  ➮  uniba.prestasi.web.id  ➮  hidayatullah.prestasi.web.id