Re: FP number syntax (was: ANN: DX-Forth 4.57)

Liste des GroupesRevenir à cl forth 
Sujet : Re: FP number syntax (was: ANN: DX-Forth 4.57)
De : albert (at) *nospam* spenarnc.xs4all.nl
Groupes : comp.lang.forth
Date : 25. Dec 2024, 16:50:16
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$4f2e477f$156f0639@793727a21ce5d063>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <2024Dec25.123616@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
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.

A more simple approach is:
stick to case-sensitive.
In decimal 1E is a floating point number, as long as the floating
point number is loaded.
In HEX 1E is not a floating point number.
1e is not reconfignized anyhow, unless BASE is incremented a lot.

For hex instead use _ for the exponent sign.
1E_0 OK
.S
S[ ] OK
DECIMAL
.FS
3.000000000000000000E1

S[ ] OK

The advantage is that hex allows to represent floating point
numbers exactly.

(You guessed it, it is the ciforth way.)

>
- anton
--
Temu exploits Christians: (Disclaimer, only 10 apostles)
Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
And Gifts For Friends Family And Colleagues.

Date Sujet#  Auteur
8 Dec 24 * ANN: DX-Forth 4.5756dxf
9 Dec 24 `* Re: ANN: DX-Forth 4.5755Hans Bezemer
10 Dec 24  +* Re: ANN: DX-Forth 4.575dxf
10 Dec 24  i+- Re: ANN: DX-Forth 4.571albert
10 Dec 24  i`* Re: ANN: DX-Forth 4.573albert
10 Dec 24  i `* Re: ANN: DX-Forth 4.572dxf
11 Dec 24  i  `- Re: ANN: DX-Forth 4.571dxf
24 Dec 24  `* Re: ANN: DX-Forth 4.5749John
24 Dec 24   `* Re: ANN: DX-Forth 4.5748dxf
25 Dec 24    `* Re: ANN: DX-Forth 4.5747John
25 Dec 24     +* Re: ANN: DX-Forth 4.5745dxf
25 Dec 24     i`* FP number syntax (was: ANN: DX-Forth 4.57)44Anton Ertl
25 Dec 24     i +* Re: FP number syntax42minforth
26 Dec 24     i i`* Re: FP number syntax41dxf
26 Dec 24     i i +* Re: FP number syntax39Paul Rubin
26 Dec 24     i i i+* Re: FP number syntax36dxf
26 Dec 24     i i ii+* Re: FP number syntax30Paul Rubin
26 Dec 24     i i iii+* Re: FP number syntax2minforth
27 Dec 24     i i iiii`- Re: FP number syntax1dxf
26 Dec 24     i i iii`* Re: FP number syntax27Anton Ertl
27 Dec 24     i i iii +- Re: FP number syntax1dxf
27 Dec 24     i i iii +* Re: FP number syntax17Paul Rubin
27 Dec 24     i i iii i+* Re: FP number syntax5mhx
27 Dec 24     i i iii ii`* Re: FP number syntax4minforth
27 Dec 24     i i iii ii `* Re: FP number syntax3albert
27 Dec 24     i i iii ii  `* Re: FP number syntax2minforth
28 Dec 24     i i iii ii   `- Re: FP number syntax1albert
31 Dec 24     i i iii i`* Re: FP number syntax11Anton Ertl
1 Jan 25     i i iii i `* Re: FP number syntax10dxf
1 Jan 25     i i iii i  `* Re: FP number syntax9Bernd Linsel
1 Jan 25     i i iii i   `* Re: FP number syntax8dxf
1 Jan 25     i i iii i    +- Re: FP number syntax1dxf
1 Jan 25     i i iii i    `* Re: FP number syntax6Anton Ertl
1 Jan 25     i i iii i     +- Re: FP number syntax1HenryHH
1 Jan 25     i i iii i     `* Re: FP number syntax4dxf
1 Jan 25     i i iii i      +* Re: FP number syntax2mhx
1 Jan 25     i i iii i      i`- Re: FP number syntax1albert
1 Jan 25     i i iii i      `- Re: FP number syntax1dxf
27 Dec 24     i i iii `* Re: FP number syntax8albert
28 Dec 24     i i iii  +- Re: FP number syntax1dxf
31 Dec 24     i i iii  `* Re: FP number syntax6Anton Ertl
2 Jan 25     i i iii   `* Re: FP number syntax5Anton Ertl
3 Jan 25     i i iii    `* Re: FP number syntax4albert
3 Jan 25     i i iii     `* Re: FP number syntax3Anton Ertl
4 Jan 25     i i iii      +- Re: FP number syntax1minforth
4 Jan 25     i i iii      `- Re: FP number syntax1albert
3 Jan 25     i i ii`* Re: FP number syntax5dxf
3 Jan 25     i i ii +* Re: FP number syntax2minforth
3 Jan 25     i i ii i`- Re: FP number syntax1dxf
3 Jan 25     i i ii `* Re: FP number syntax2Anton Ertl
3 Jan 25     i i ii  `- Re: FP number syntax1minforth
26 Dec 24     i i i`* Re: FP number syntax2Anton Ertl
26 Dec 24     i i i `- Re: FP number syntax1dxf
26 Dec 24     i i `- Re: FP number syntax1mhx
25 Dec 24     i `- Re: FP number syntax (was: ANN: DX-Forth 4.57)1albert
26 Dec 24     `- Re: ANN: DX-Forth 4.571dxf

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal