Constants
and
Variables
Constants
Fixed Point
Constants
Floating Point Constants
Variables
14
Mathematical problems usually contain some
data
that
does
not
change
throughout
the
entire problem,
and
other
data
that
may
change
many
times
during
calculation.
These two kinds of
data
are
referred to as "constants"
and
"variables," respectively.
Both constants
and
variables can
be
used
in
FORTRAN
if
they are written so
that
the
processor
can
distinguish one from
the
other.
A constant is
any
number
which is
used
in
computations without change from one
execution of
the
program
to
the
next.
It
appears
in
its
actual
numerical form
in
the
source statement.
In
the
statement
6
is
a constant
because
it
appears in its actual numerical form. (The asterisk indi-
cates
the
arithmetic operation of multiplication.)
You
can
write constants
in
floating
point
or fixed
point
form.
Definition:
Example:
Definition:
Example:
A fixed
point
constant is
written
without
a decimal point,
using
the
digits
0,
1,
. . .
9.
A
preceding
plus sign
or
minus
sign
is
optional.
The
length of
the
constant cannot exceed
4 digits.
o
+3
-2496
48
Any
number
written
with
a decimal point, using
the
digits
0,
1,
. . .
9.
A
preceding
plus
or
minus sign is optional. An
unSigned constant is assumed to
be
positive.
The
constant
may
contain an exponent,
The
exponent, pre-
ceded
by
the
letter E,
may
have
a preceding plus or minus
sign.
All floating
point
constants
are
converted to an 8-digit man-
tissa with a 2-digit exponent.
Constants in
input
data
may
contain
up
to
20
digits,
but
only
the
first eight significant digits will
be
carried in the
mantissa during calculation.
42.
1.13
.0046
5000.
6.0E3
6.0E+3
4264.44
-.00004
(6.0 X 10
3
or 6000)
(6.0 X 10
3
or 6000)
When
a
quantity
in
a
FORTRAN
problem is
not
constant,
that
is,
when
its value varies
for different executions of
the
program,
or
varies
at
different stages within
the
pro-
gram,
it
is
known
as a variable quantity. Variable quantities
are
given names so