home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / l3p040.seq < prev    next >
Text File  |  1990-04-01  |  909b  |  22 lines

  1. \ Lesson 3 Part 4  ( F-PC 3.5 Tutorial by Jack Brown )
  2.  
  3. COMMENT:
  4. In part 3 of lesson 4 we introduced the words DECIMAL  OCTAL and HEX for
  5. switching the radix of Forth's number system to 10, 8 and 16
  6. respectively.  These words are included as part of the F-PC system.
  7. However F-PC does not include a word to set the radix to 2 so that we
  8. can study binary or base 2 numbers.  We can easily make a word called
  9. BINARY that will switch the radix to 2.
  10. COMMENT;
  11.  
  12. : BINARY ( -- )  2 BASE ! ;
  13.  
  14.  
  15. :  .H ( n -- ) HEX     . DECIMAL ;  \ Display top number in HEX
  16. : U.H ( n -- ) HEX    U. DECIMAL ;  \ Display top as unsigned HEX
  17. :  .O ( n -- ) OCTAL   . DECIMAL ;  \ Display top number in OCTAL
  18. : U.O ( n -- ) OCTAL  U. DECIMAL ;  \ Display top as unsigned OCTAL
  19. :  .B ( n -- ) BINARY  . DECIMAL ;  \ Display top number in BINARY
  20. : U.B ( n -- ) BINARY U. DECIMAL ;  \ Display top as unsigned BINARY
  21.  
  22.