Friday 28 December 2012

Integer Numerals

                                                                              Integer Numerals

They are numerical constants that identify integer decimal values. Notice that to express a numerical constant we
do not have to write quotes (") nor any special character. There is no doubt thatit is a constant: whenever we
write 1776in a program, we will be referring to the value 1776.
In addition to decimal numbers (those that all of us are used to use every day) C++ allows the use as literal
constants of octal numbers (base 8) and hexadecimalnumbers (base 16). If we want to express an octal number
we have to precede it with a 0(zero character). And in order to express a hexadecimal number we have to precede
it with the characters 0x(zero, x). For example, the following literal constants are all equivalent to each other:




All of these represent the same number: 75 (seventy-five) expressed as a base-10 numeral, octal numeral and
hexadecimal numeral, respectively.
Literal constants, like variables, are considered to have a specific data type. By default, integer literals are of type
int. However, we can force them to either be unsigned by appending the ucharacter to it, or long by appending l: 




In both cases, the suffix can be specified using either upper or lowercase letters.

Literals

Literals are used to express particular values within the source code of a program. We have already used these
previously to give concrete values to variables or to express messages we wanted our programs to printout, for
example, when we wrote:




the 5in this piece of code was a literal constant.
Literal constants can be divided in Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values.


Constants
Constants are expressions with a fixed value.

No comments:

Post a Comment