Liste des Groupes | Revenir à cl forth |
dxf <dxforth@gmail.com> writes:On 25/12/2024 3:06 pm, John wrote:>And not sure how to enter decimals, I though maybe entering a ".0" after my numbers would flag them as reals not integers, but...>
3.14 2.96 <return> does not put both numbers on the stack
Those would be illegal numbers - neither reals nor integers.
At least in standard Forth. In traditional Forth 3.14 and 2.96 are
double-cell integers (with the value #314 and #296). And backwards
compatibility demands that they should not be recognized as FP values.
>
In Gforth snapshots from the last few years (not available for CP/M,
sorry) you get the following when you type in "3.14":
>
*terminal*:2:1: warning: '3.14' is a double-cell integer; type `help' for more info ok 2
>
HELP then says:
>
To input floating-point numbers, use an exponent, e.g. "1e".
To input double-cell integers without warnings, use a base-prefix and put
the '.' only in the last position, e.g. "#1.".
>
But you can also do
>
' rec-float ' forth-recognize defer@ >stack
>
and then you can do things like
>
3.14 2.96 f* cr f.
>
which produces the following output:
>
*terminal*:18:1: warning: float without 'e' is non-standard
*terminal*:18:6: warning: float without 'e' is non-standard
9.2944 ok
>
You can also disable the warnings with "warnings off".
>
Followups set to comp.lang.forth.
>--
- anton
Les messages affichés proviennent d'usenet.