( 8 July 88 -- MFB ) OFF PRINTLOAD ( START OF FILE DEMO#S.4th) ( 5 JUNE 1982 Donald M. Ramsey ) ( This file demonstrates the use of the words in file SHARPS.4TH for printing single and double precision numbers in a specified field width with and without sign. To get the demo: " DEMO#S.4TH" LOAD ) " SHARPS.4TH" LOAD 2 BLOCK FW ( variable field width will be used) 5 FW ! ( use field width of five for now) : S.# ( single precision number without decimal pt or sign) DOUBLE ( convert number to double precision) <# #S FW @ #> ( convert number to string within #BUFFER) ." ( print contents of #BUFFER) ; : D.# ( double precision number w/o decimal pt or sign) <# #S FW @ #> ." ; : S2.# ( single precision with 2 decimal places and forced sign) DOUBLE <# # # #. #S #+ FW @ #> ." ( note that the field specifier <#...#> works backwards, ie. you specify output starting with right end of number) ; : D3.# ( double precision with 3 decimal places and optional sign) <# # # # #. #S #- FW @ #> ." ; : DN.# ( double prec. with field width passed on stack) <# #S #- 3 PICK #> ." DROP ; ON PRINTLOAD ( print a single precision number rt justified in five char field) 123 S.# ( print a double precision number) 123, D.# ( print a single precision number with 2 places to rt of decimal pt) ( put a sign in number even if positive) 123 S2.# ( print a double precision number with 3 places to rt) ( put a sign in number if it is negative) 123, D3.# ( print a double prec. number with field width = "n" ) 10 ( field width) 123, DN.# 5 -7,154 DN.# ( change FW to other field widths and try experimenting! ) ( END OF FILE DEMO#S)