home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
source
/
l3p040.seq
< prev
next >
Wrap
Text File
|
1990-04-01
|
909b
|
22 lines
\ Lesson 3 Part 4 ( F-PC 3.5 Tutorial by Jack Brown )
COMMENT:
In part 3 of lesson 4 we introduced the words DECIMAL OCTAL and HEX for
switching the radix of Forth's number system to 10, 8 and 16
respectively. These words are included as part of the F-PC system.
However F-PC does not include a word to set the radix to 2 so that we
can study binary or base 2 numbers. We can easily make a word called
BINARY that will switch the radix to 2.
COMMENT;
: BINARY ( -- ) 2 BASE ! ;
: .H ( n -- ) HEX . DECIMAL ; \ Display top number in HEX
: U.H ( n -- ) HEX U. DECIMAL ; \ Display top as unsigned HEX
: .O ( n -- ) OCTAL . DECIMAL ; \ Display top number in OCTAL
: U.O ( n -- ) OCTAL U. DECIMAL ; \ Display top as unsigned OCTAL
: .B ( n -- ) BINARY . DECIMAL ; \ Display top number in BINARY
: U.B ( n -- ) BINARY U. DECIMAL ; \ Display top as unsigned BINARY