Thursday 18 August 2011

Integer vs Pointer




The terms integer and pointer are used in most of the programming
languages. In computer programming languages, integer is referred as
any data type that represents a subset of mathematical integers whereas
pointers are defined as a type whose value points to or refers directly
to another value that is stored somewhere else in computer’s memory
using the address of the value.


Integer


In computer programming languages, an
integer is a data type that represents subset of mathematical integers.
The value of datum that has an integral part is the mathematical integer
to which it corresponds. The value is stored in the memory of computer
in this way by representing the datum. The integral types can be signed
or unsigned. Signed means they can represent negative integers and
unsigned mean they can represent non-negative integers.


A string of bits is the most common way
of representing a positive integer. This is done by using the binary
numeral system. There is a variation in the order of bits. The precision
or width of an integer type represents the number of bits.


In binary numeral system, the negative
numbers can be represented by three ways. This can be done by one’s
complement, two’s complement or sign-magnitude. However, there is
another method to represent integers and it is called binary-coded
decimal. But this method is rarely used these days.


Different integral types are supported
by different CPUs. Both signed as well as unsigned types are supported
by different hardware but there are some fixed width sets.


Pointer


In computer programming language,
a pointer is defined as the data type whose value points to or directly
refers to another value that is stored somewhere else in the memory of
the computer. Pointers takes place of general
purpose registers in case of high level languages whereas in low level
language such as machine code or assembly language, it is done in
available memory. A location in the memory is referenced by the pointer.
A pointer can also be defined a less subtracted or simple
implementation of more abstracted data type. Pointers are supported by
different programming languages but there are some restrictions on the
use of pointers in some languages.


Performance can be improved
significantly in case of repetitive operations such as lookup tables,
tree structures, strings and control tables. In procedural programming,
pointers are also used in holding addresses of entry points. However, in
object oriented programming, pointers are used to bind methods in
functions.


Although pointers are being used to
address the references but they can be applied more properly to data
structures. There are certain risks that are associated with pointers
because they allow protected as well as unprotected access to memory
addresses of the computer.

No comments:

Post a Comment