Integers
An integer data type in computing is that it can represent a finite subset of the integers. The largest number that can represent depends on the size of the space used by the data types integer data available and its size depends on the programming language used as well as architecture. For example, if to store an integral number of 4-byte available memory fear that:
4x8 = 4 bytes = 32 bits
With 32 bits can represent 232 values = 4294967296:
Only positive (unsigned): 0 to 4294967295
Positive and negative (integers): from -2147483648 to 2147483647
Floating
The way in which computer architecture solves the problem of representing real numbers is through floating point numbers. A floating point number is divided into 3 sections of bits: sign, signifier and exponent.
Example 8-bit floating point
b7 b6 b5 b4 b3 b2 b1 b0
\ pm \ pm 2 ^ 1 2 ^ 0 2 ^ {- 1} 2 ^ {- 2} 2 ^ {-} 2 ^ {3 - 4}
This example consists of a floating hypothetical 8-bit integer in which the bit 7 corresponds to the sign of the number, the sign bit of the exponent 6, bits 5 and 4 the exponent bits and the significant 3,2,1 and 0.
With floating point numbers there is a limited range to represent quantities, using numbers out of range will result in overflow or underflow.
There are a finite number of real numbers that can be represented within the range.
The signifier is normalized.
The most common way is to use floating point as dictated by the IEEE 754
Integers and Floats
- unsigned (int) 32 0 <= X <= 4,294,967,295. big Numbers
- int (signed) 32 -2,147,483,648 <= X <= 2,147,483,647 small numbers, control loops
- unsigned long 32 0 <= X <= 4,294,967,295 astronomical distances
- enum 32 -2,147,483,648 <= X <= 2,147,483,647 sets of sorted values
- long (int) 32 -2,147,483,648 <= X <= 2,147,483,647 Big Numbers
- float 32 1.18e-38 <= | X | <= 3.40e38 scientific accuracy (7-digit)
No hay comentarios:
Publicar un comentario