version 1.209, 2010/03/05 14:28:13
|
version 1.210, 2010/03/06 16:12:56
|
Line 1753 two cells (not-necessarily double-cell n
|
Line 1753 two cells (not-necessarily double-cell n
|
mixed single-cell and double-cell operations |
mixed single-cell and double-cell operations |
@item f |
@item f |
floating-point (note that in stack comments @samp{f} represents flags, |
floating-point (note that in stack comments @samp{f} represents flags, |
and @samp{r} represents FP numbers). |
and @samp{r} represents FP numbers; also, you need to include the |
|
exponent part in literal FP numbers, @pxref{Floating Point Tutorial}). |
@end table |
@end table |
|
|
If there are no differences between the signed and the unsigned variant |
If there are no differences between the signed and the unsigned variant |
(e.g., for @code{+}), there is only the prefix-less variant. |
(e.g., for @code{+}), there is only the prefix-less variant. |
|
|
Forth does not perform type checking, neither at compile time, nor at |
Forth does not perform type checking, neither at compile time, nor at |
run time. If you use the wrong oeration, the data are interpreted |
run time. If you use the wrong operation, the data are interpreted |
incorrectly: |
incorrectly: |
|
|
@example |
@example |
Line 2559 Computer Scientist Should Know About Flo
|
Line 2560 Computer Scientist Should Know About Flo
|
Computing Surveys 23(1):5@minus{}48, March 1991}. |
Computing Surveys 23(1):5@minus{}48, March 1991}. |
|
|
In Forth source code literal FP numbers need an exponent, e.g., |
In Forth source code literal FP numbers need an exponent, e.g., |
@code{1e0}; this can also be written shorter as @code{1e}, |
@code{1e0}; this can also be written shorter as @code{1e}, longer as |
@code{+1.0e+0}, and many variations in between. The reason for this |
@code{+1.0e+0}, and many variations in between. The reason for this is |
is that, for historical reasons, Forth interprets a decimal point |
that, for historical reasons, Forth interprets a decimal point alone |
alone (e.g., @code{1.}) as indicating a double-cell integer. Another |
(e.g., @code{1.}) as indicating a double-cell integer. Examples: |
requirement for literal FP numbers is that the current base is |
|
|
@example |
|
2e 2e f+ f. |
|
@end example |
|
|
|
Another requirement for literal FP numbers is that the current base is |
decimal; with a hex base @code{1e} is interpreted as an integer. |
decimal; with a hex base @code{1e} is interpreted as an integer. |
|
|
Forth has a separate stack for FP numbers.@footnote{Theoretically, an |
Forth has a separate stack for FP numbers.@footnote{Theoretically, an |