home *** CD-ROM | disk | FTP | other *** search
- \ Alternate to Problem 2.17 (d)
-
- \ In this solution we use the right justified display operator .R
- \ to avoid the use of 1 BACKSPACES which was used to back up over
- \ the trailing blank that . provides.
- \ We have also replaced the phrase 355 * 113 /MOD
- \ with the phrase 355 113 */MOD for a greater range of radii.
- \ */MOD will first multiply by 355 leaving a 32 bit intermediate
- \ product and then divide this 32 bit product by 113.
-
-
- \ Compute area of a circle to three decimal places.
- : CIRCLE_AREA ( r -- )
- DUP * 355 113 */MOD
- ." Area = " 5 .R \ ( 8 EMIT ) 1 BACKSPACES
- ASCII . EMIT
- 5 0 DO
- 10 * 113 /MOD 1 .R \ ( 8 EMIT ) 1 BACKSPACES
- LOOP DROP ;
-
- : TEST_CIRC ( -- )
- 11 1 DO CR I CIRCLE_AREA LOOP ;
-
-
-
-
-