Sharp OZ-707 Operation Manual - Page 22

Hexadecimal, Numbers, Variables - area code

Page 22 highlights

Hexadecimal Numbers The decimal system is only one of many different ~ystems to rep~esent numbers. Another that is quite important when uSing computer.s IS the hexadecimal system. The hexadecimal system is base~ on 16 Instead of 10. To write hexadecimal numbers you use the familiar 0 to 9 and six more "digits": A, B, C, 0, E, and F. These correspond to 10, 11, 12 13 14 and 15. When you want the Card to treat a number as he~ad~ci~al, put an ampersand (&) character and "H" in front of the numeral: &HA =10 &H10 = 16 &H100 = 256 &HFFFF = 65535 Variables Computers are made up of many tiny memory are.as called bytes. Each byte can be thought of as a single character. For Instance, the word "card" requires four bytes of memory because there are four characters in it. To see how many bytes are available for use, simply enter FREO and press IENTER I . The number displayed is the number of bytes available for writing programs. This technique works well for words, but is very ineffici~nt when you try to store numbers. For this reason, numbers are stored In a coded fashion. Thanks to this coding technique, the Card can store large numbers in only 8 bytes (or 13 bytes in double-precision mode). The largest number that can be stored is +9.999999999E + 99 (or 9.99999999999999999990 + 99 in double-precision). The smallest number is 1.E-99. This gives you quite a range to choose from. However, if the result of a calculation exceeds this range, the computer will let you know by displaying an error message on the screen (see Appendix A). To see it right now, enter: 911 EXP ~ 9 9 00 9 IENTER I 9E99*9 Overflow 32 To get the Card working properly again, just press the ICeCE 1key. But how do you go about storing all these numbers and strings? It's really very easy. The Card uses names for different pieces of data. Let's store the number 556 in the Card. You may call this number by any name you wish, but for this exercise, let's use the letter R. The statement LET can be used to instruct the Card to assign a value to a variable name, but only in a program statement. However, the LET command is not necessary, so we will not use it often. Now, enter: R = 556 and press 1ENTER I. The Card now has the value 556 associated with the letter R. These letters that are used to store information are called variables. To see the content of the variable R, press the ICeCE I o=J key, the key and the 1ENTER 1key. The Card responds by showing you the value 556 on the right of your display. This is useful when writing programs and formulas. Next, let's use the R variable in a simple formula. In this formula, the variable R stands for the radius of a circle whose area we want to find. The formula for the area of a circle is: A = 1tR2. Type in the following: R yz 2 CKJ I It III ENTER I RA 2*PI 9711 79. 3866 The result is 971179.3866. This technique of using variables in equations will become more understandable as we get into writing programs. So far, we've only discussed numeric variables. What about storing alphabetic characters? Well, the idea is the same, but, so that the Card will know the difference between the two kinds of variables, add a $ to the variable name. For instance, let's store the word BYTE in the variable B$. Notice the $ after the B. This tells the Card that the contents of variable B$ are alphabetic, or I I I.-- string data. To illustrate this, enter the following: B$ = "B Y T E" ENTER -~-$-=-"B-Y-r-E-"- - -..... The string BYTE is now stored in the variable B$. To make sure of this, press the I CeCE 1 key and enter the following: 33

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128

Hexadecimal
Numbers
The decimal system is only one of many different
~ystems
to
rep~esent
numbers. Another that is quite important when
uSing
computer.s
IS
the
hexadecimal system. The hexadecimal system is
base~
on 16 Instead
of 10. To write hexadecimal numbers you use the familiar 0 to 9 and
six more "digits": A,
B,
C,
0,
E,
and
F.
These correspond to 10, 11,
12 13 14 and 15. When you want the Card to treat a number
as
he~ad~ci~al,
put an ampersand
(&)
character and "H" in front of the
numeral:
&HA
=10
&H10
=
16
&H100
=
256
&HFFFF
=
65535
Variables
Computers are made up of many tiny memory are.as called bytes. Each
byte can be thought of
as
a single character. For Instance, the word
"card" requires four bytes of memory because there are four characters
in it. To see how many bytes are available for use, simply enter
FREO
and press
I
ENTER
I .
The number displayed
is
the number of bytes
available for writing programs.
This technique works well for words, but
is
very
ineffici~nt
when you try
to store numbers. For this reason, numbers are stored
In
a coded
fashion. Thanks to this coding technique, the Card can store large
numbers in only 8 bytes (or 13 bytes
in
double-precision mode). The
largest number that can
be
stored is +9.999999999E + 99 (or
9.99999999999999999990 + 99 in double-precision). The smallest
number
is
1.E-99. This gives you quite a range to choose from.
However, if the result of a calculation exceeds this range, the computer
will let you know by displaying an error message on the screen (see
Appendix A). To see it right now, enter:
911
EXP
~
9
9
00
9
I
ENTER
I
32
9E99*9
Overflow
To get the Card working properly again, just press the
I
CeCE
1
key. But
how do you go about storing all these numbers and strings? It's really
very easy. The Card uses names for different pieces of data. Let's
store the number 556 in the Card. You may call this number by any
name you wish, but for this exercise, let's use the letter
R.
The
statement LET can be used to instruct the Card to assign a value to a
variable name, but only
in
a program statement. However, the LET
command
is
not necessary, so
we
will not use it often. Now, enter: R
=
556 and press
1
ENTER
I.
The Card now has the value 556 associated
with the letter
R.
These letters that are used to store information are
called variables. To see the content of the variable
R,
press the
I
CeCE
I
key, the
o=J
key and the
1
ENTER
1
key. The Card responds by showing
you the value 556 on the right of your display. This is useful when
writing programs and formulas.
Next, let's use the R variable
in
a simple formula.
In
this formula, the
variable R stands for the radius of a circle whose area we want to find.
The formula for the area of a circle is: A
=
1tR2.
Type
in
the following:
R
yz
2
CKJ
II
It
III
ENTER
I
R
A
2*PI
9711
79.
3866
The result is 971179.3866.
This technique of using variables
in
equations will become more
understandable as we get into writing programs.
So far, we've only discussed numeric variables. What about storing
alphabetic characters? Well, the idea is the same, but,
so
that the Card
will know the difference between the two kinds of variables, add a $ to
the variable name. For instance, let's store the word BYTE
in
the
variable
B$.
Notice the $ after the
B.
This tells the Card that the contents of variable
B$
are alphabetic, or
string data.
To
illustrate this, enter the following:
B$
=
"B Y T
E"
I
ENTER
II
.--
-~-$-=-"
B-Y-r-E-"
---
.....
The string BYTE
is
now stored
in
the variable
B$.
To make sure of
this, press the
I
CeCE
1
key and enter the following:
33