home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TCE Demo 2
/
TCE_DEMO_CD2.iso
/
demo_cd_.2
/
mags
/
stosser
/
stoser05.arj
/
stoser05.msa
/
A
/
46.PNE
< prev
next >
Wrap
Text File
|
1987-04-22
|
1KB
|
76 lines
STOS BITS 'N PIECES
by
Martin Cubitt July 1993
Many of you will find there are times
when you are programming STOS when you
require to convert decimal to hexa-
decimal and vice versa.
The STOS manual shows the command HEX$
(n) which converts the decimal value n
to a hexadecimal string value, for
example:
print hex$(255)
will result in $FF being printed on
screen.
The prefix $ is a computer standard to
signify that the value given is in hexa-
decimal format.
Okay, so how do you convert a hexa-
decimal number to a decimal one?
Hmmm, I cannot find this in the manual.
Well the answer is really quite simple.
Enter:
print $FF
and the computer will display 255.
So to summarise, use H$=HEX$(n) to con-
vert from decimal to hexadecimal and use
D=$n to convert from hexadecimal to
decimal.
The same is true with binary except
that the prefix is %, not $.
So the command:
print bin$(5)
will display %101
and the command:
print %101
will display 5.
Both HEX$(n) and BIN$(n) return string
values, that is the values returned are
NOT numbers but characters. So to store
them you must use a string variable such
as H$ or B$. Not that the prefix of $ or
% will be stored in the string. This can
be removed with the command:
H$=hex$(255)-"$"
or
b$=bin$(255)-"%"
CUBITTM/STOS0003/190793