EasyManuals Logo
Home>HP>Calculator>HP-11C

HP HP-11C User Manual

HP HP-11C
264 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #219 background imageLoading...
Page #219 background image
Section
11:
Programming
Techniques
217
Random
Numbers
The HP-11C
has
a
convenient
built-in
function
that
generates
pseudo-random
numbers
([RAN#]).
By
pseudo-random
we
mean
that
no
calculator
or
computer,
no
matter
how
powerful,
can
generate
a
totally
random
number.
The
nature
of
the
machine
is
such
that
it
performs
a
sequence
of
established
steps
on
an
input
and
produces
a
predictable
result.
So
the
random
number
generator
on
the
HP-11C
takes
a
random
‘‘seed”,
stored
by
the
user,
and
performs
an
operation
on
it
to
produce
a
generally
unpredictable
(by
the
user)
result.
This
result
is
always
a
number
between
0
and
1,
exclusive
of
1.
There
are
several
common
uses
for
random
numbers,
but
they
are
very
frequently
found
in
game
programs.
This
seems
reasonable
because
no
one
likes
to
play
against
a
completely
predictable
and
redundant
opponent.
Submarine
Hunt
is
a
good
example
of
such
a
game.
The
game
requires
a
random
initial
placement
of
the
submarine
and
random
evasive
moves.
Notice
that
the
program
requires
two
random
integers,
the
x
and
y
coordinates,
that
fall
between
0
and
9
inclusive.
But
the
random
number
generator
only
generates
numbers
between
0
and
1
exclusive
of
1.
This
turns
out
to
be
no
problem.
Multiplying
the
output
of
the
random
number
generator
by
10
yields
numbers
from
0
to
10
exclusive
of
10.
Taking
the
integer
portion
of
this
result
gives
the
set
of
whole
numbers
between
0
and
9
inclusive,
which
is
what
we
want.
The
subroutine
following
9
shows
the
actual
keystrokes.
To
illustrate
the
ease
in
which
different
ranges
of
random
numbers
may
be
generated
let’s
take
another
example.
Suppose
you
need
a
real
number
between
the
limits
34.5
and
98.36
including
the
lower
bound
and
excluding
the
upper
bound.
The
routine
need
only
generate
values
between
0
and
63.86
(98.36
-
34.50)
to
which
the
value
34.5
will
be
added.
This
range
is
easily
generated
by
multiplying
63.86
by
the
output
from
the
random
number
generator.
User-Definable
Keys
Among
the
most
useful
features
on
the
HP-11C
are
the
five
user-
definable
keys:
[A],
(B],
[C],
(D],
and
[E].
These
keys
are
particularly
useful
for
three
applications:
1.
Storing
data
in
specific
registers
(see
page
213).

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the HP HP-11C and is the answer not in the manual?

HP HP-11C Specifications

General IconGeneral
BrandHP
ModelHP-11C
CategoryCalculator
LanguageEnglish

Related product manuals