Category:C Data Type

From ElectroDragon Wiki
(Redirected from C Data Type)

Data type

Classic basic primitive types may include:

  • Character (character, char);
  • Integer (integer, int, short, long, byte) with a variety of precisions;
  • Floating-point number (float, double, real, double precision);
  • Fixed-point number (fixed) with a variety of precisions and a programmer-selected scale.
  • Boolean, logical values true and false.
  • Reference (also called a pointer or handle), a small value referring to another object's address in memory, possibly a much larger one.

More sophisticated types which can be built-in include:

  • Tuple in Standard ML, Python, Scala
  • List in Common Lisp, Scheme, Haskell
  • Complex number in C99, Fortran, Common Lisp, Python, D, Go
  • Rational number in Common Lisp, Haskell
  • Associative array in Perl, Python, Ruby, Javascript, Lua, D, Go
  • First-class function, in all functional languages, Javascript, Lua, D, Go, and in newer standards of C++, Java, C#, Perl
type width default signed range unsigned range
bool 1 bit unsigned - 0, 1
char 8 bits, 1 byte signed -128 to +127 0 to +255
short 16 bits, 2 bytes signed -32,768 to +32,767 0 to +65,535
int 16 bits, 2 bytes signed -32,768 to +32,767 0 to +65,535
long 32 bits, 4 bytes signed -2,147,483,648 to +2,147,483,647 0 to +4,294,967,295
float 4 bytes IEEE 754 signed 1.175494351E-38 to 3.402823466E+38
pointer 1, 2, 3 or 4 bytes generic


Easy to remember integer data types :

data type width signed/
unsigned
range
s8 8 bits (1 byte) signed -128 to +127
s16 16 bits (2 bytes) signed -32,768 to +32,767
s32 32 bits (4 bytes) signed -2,147,483,648 to +2,147,483,647
s64* 64 bits (8 bytes) signed −9,223,372,036,854,775,808
to 9,223,372,036,854,775,807
u8 8 bits (1 byte) unsigned 0 to +255
u16 16 bits (2 bytes) unsigned 0 to +65,535
u32 32 bits (4 bytes) unsigned 0 to +4,294,967,295
u64* 64 bits (8 bytes) unsigned 0 to +18,446,744,073,709,551,615


Data Type

- - -
Byte 8 bit Example
Int Example Example
Char Example Example
Hex Example Example


Reference

This category currently contains no pages or media.