Download RSC-FORTH User`s Manual
Transcript
DECIMAL
456. CR D.
456
23145. CR D.
23145
-879. CR D.
-879
-1289.4 CR D.
-12894
It is often desirable to print the data right-justified. The word D.R
("d-dot-r") prints a double-precision number, right-justified in a variable
width field. The top number on the stack is the column in which the least
significant digit of the data is to be printed, while the second number is the
double-precision number (the data) to be printed. Try the example data one
more time, but right-justify it in the 30-column field as follows (if the
number prints in the wrong column, you forgot to switch back to decimal)
456. 30 CR D.R
456
23145. 30 CR D.R
23145
-879. 30 CR D.R
-879
-1289.4 30 CR D.R
-12894
Define a word to print multiple double-precision numbers right-justified 15
columns.
: PRINT-RIGHT ( N ---.)
0 DO CR 30 D.R LOOP CR ;
Enter the data on the stack and print it with PRINT-RIGHT . Place the numbers
and the number of items on the stack before calling PRINT-RIGHT .
456. 23145. -879. -12894.
4 PRINT-RIGHT
-12894
-879
23145
456
5.2.3 Other 32-Bit FORTH Operators
There are several other double-precision FORTH words which are analogous to the
single-precision operations.
Double-precision add D+ ("d-plus") operates in the same manner as + , except
it uses the top two double-precision numbers on the stack as inputs and leaves
one double-precision number, e.g.,
3456. 6576. D+ D. <RETURN> 10032
5-4