In computer science, primitive data type is either of the following:
- a basic type is a data type provided by a programming language as a basic building block. Most languages allow more complicated composite types to be recursively constructed starting from basic types.
- a built-in type is a data type for which the programming language provides built-in support.
primitive Data types 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.
Integer numbers
An integer data type can hold a whole number, but no fraction. Integers may be either signed (allowing negative values) or unsigned (nonnegative values only). Typical sizes of integers are:
| Size | Names | Signed Range | Unsigned Range |
|---|---|---|---|
| 8 bits | Byte | −128 to +127 | 0 to 255 |
| 16 bits | Word, short int | −32,768 to +32,767 | 0 to 65,535 |
| 32 bits | Double Word, long int (win32, win64, 32-bit Linux[1]) | −2,147,483,648 to +2,147,483,647 | 0 to 4,294,967,295 |
| 64 bits | long int (C in 64-bit linux[1]), long long (C), long (Java, the signed integer variant only[2])) | −9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 | 0 to 18,446,744,073,709,551,615 |
| unlimited | Bignum |
Booleans
boolean values may be implicitly converted to integers, according to the mapping false → 0 and true → 1 (for example,
true + true would be a valid expression evaluating to 2). The boolean type bool in C++ is considered an integral type and is a cross between numeric type and a logical type.
No comments:
Post a Comment