Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 94:09:25 |
Calls: | 290 |
Calls today: | 1 |
Files: | 904 |
Messages: | 76,378 |
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.
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--