Integer (data type)

format_list_bulleted Contenido keyboard_arrow_down
ImprimirCitar

An integer data type in computing is a data type that can represent a finite subset of the integers. The largest number that it can represent depends on the space used by the data and the possibility (or not) of representing negative numbers. The available integer data types and their size depend on the programming language used as well as the architecture in question. For example, if to store an integer we have 4 bytes of memory we have to:

4 bytes = 4 × 8 = 32 bits
With 32 bits can be represented 232=4294967296:
  • Only Positive (non-signed)
  • Positive and negative (signed inflows): from -2147483648 to 2147483647

Integer Operations

The typical arithmetic operations: addition, subtraction, multiplication, and division can be performed on integer data. In the case of division, the result could be a real value, in that case, if the result is to be stored as an integer the decimal part of the result should be removed, in principle there are two methods to do so:

  • The round: Approximate the real value to the nearest integer (e.g.: 3,8-- or 3,2-- or 3,3)
  • The truncation: Eliminate from real value the decimal part (e.g.: 3,8-- 20053 / 3,2-- 20053)

Another important operation that can be performed with integers is the operation of modulo or remainder of integer division, that is:

184 divided 3 = 61 (residue 1) -- 2005 module 3 = 1

In general, the operation module satisfies that:

a mod b = c
  • c ≥ 0
  • c B
  • Yeah. c equals 0 -- 2005 a is multiple b
  • Yeah. c equals 0 and b equals 2n (singing) n a full number greater or less than 0) -- ▪ a (It's Par)

Overflow

If in a computer program an attempt is made to assign an integer a value that is outside the range of values that can be represented (Ex: a=240) an error occurs that is known by the name of overflow (overflow in English). When this happens, the program would normally continue to run as if nothing had happened, but the new value would be set to 0 if the overflow occurred on an unsigned integer; and at -231 if it occurs on a signed integer.

Contenido relacionado

Library (computer)

In computing, a library or, called by language defect, library is a set of functional implementations, coded in a programming language, which provides a...

Pythagoras theorem

In mathematics, the Pythagorean theorem is a relationship in Euclidean geometry between the three sides of a right triangle. It states that the area of the...

Numerical analysis

The numerical analysis or numerical calculation is the branch of mathematics in charge of designing algorithms to simulate approximations of solutions to...
Más resultados...
Tamaño del texto: