Discussion:
ANN: DX-Forth 4.57
(too old to reply)
dxf
2024-12-08 03:01:12 UTC
Permalink
DX-Forth is a Forth language compiler and development system
for MS-DOS and CP/M-80 operating systems. It is intended to
be a complete, easy to use, programming tool for the creation
of turnkey applications.

What's new:

v4.57 2024-12-08

+ added - removed * fixed ! changed = updated

+ (NUMBER) \CHAR CSKIP "
! INTEGER moved to TOOLS
! DOSLIB: strings, parsing, files

Downloads:

DXCPM457.ZIP (CP/M-80)
DXDOS457.ZIP (MS-DOS)

https://drive.google.com/drive/folders/1kh2WcPUc3hQpLcz7TQ-YQiowrozvxfGw
Hans Bezemer
2024-12-09 08:28:37 UTC
Permalink
Post by dxf
DX-Forth is a Forth language compiler and development system
for MS-DOS and CP/M-80 operating systems. It is intended to
be a complete, easy to use, programming tool for the creation
of turnkey applications.
v4.57 2024-12-08
+ added - removed * fixed ! changed = updated
+ (NUMBER) \CHAR CSKIP "
! INTEGER moved to TOOLS
! DOSLIB: strings, parsing, files
DXCPM457.ZIP (CP/M-80)
DXDOS457.ZIP (MS-DOS)
https://drive.google.com/drive/folders/1kh2WcPUc3hQpLcz7TQ-YQiowrozvxfGw
Congratulations! It's nice to see such compilers remain maintained and
relevant!

Hans Bezemer
dxf
2024-12-09 23:39:47 UTC
Permalink
...
Congratulations! It's nice to see such compilers remain maintained and relevant!
Thanks. Not sure about relevant :) It's nevertheless interesting to see the odd
user get some use out of it. Even more of an eyebrow raiser is when they go along
with archaisms such as screens for source.


a***@spenarnc.xs4all.nl
2024-12-10 10:35:31 UTC
Permalink
--
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.
a***@spenarnc.xs4all.nl
2024-12-10 10:39:37 UTC
Permalink
Post by Hans Bezemer
Post by Hans Bezemer
...
Congratulations! It's nice to see such compilers remain maintained and
relevant!
Thanks. Not sure about relevant :) It's nevertheless interesting to see the odd
user get some use out of it. Even more of an eyebrow raiser is when they go along
with archaisms such as screens for source.
http://youtu.be/kYvYu5AfSxg
When I was forced to do line by line including of source,
I needed buffers to hold a piece of the files.
The buffers used for blocks are perfectly suited for this.

Not to mention that a 16 by 64 block of code is a perfect
match for Forth, for a multi purpose library.

Groetjes Albert
--
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.
dxf
2024-12-10 10:59:30 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
Post by Hans Bezemer
Post by Hans Bezemer
...
Congratulations! It's nice to see such compilers remain maintained and
relevant!
Thanks. Not sure about relevant :) It's nevertheless interesting to see the odd
user get some use out of it. Even more of an eyebrow raiser is when they go along
with archaisms such as screens for source.
http://youtu.be/kYvYu5AfSxg
When I was forced to do line by line including of source,
I needed buffers to hold a piece of the files.
The buffers used for blocks are perfectly suited for this.
Not to mention that a 16 by 64 block of code is a perfect
match for Forth, for a multi purpose library.
Personally I love the editing environment screens afford - small,
modular, no information overload.
a***@spenarnc.xs4all.nl
2024-12-11 10:13:47 UTC
Permalink
Post by dxf
Post by a***@spenarnc.xs4all.nl
Post by Hans Bezemer
Post by Hans Bezemer
...
Congratulations! It's nice to see such compilers remain maintained and
relevant!
Thanks. Not sure about relevant :) It's nevertheless interesting to see the odd
user get some use out of it. Even more of an eyebrow raiser is when they go along
with archaisms such as screens for source.
http://youtu.be/kYvYu5AfSxg
When I was forced to do line by line including of source,
I needed buffers to hold a piece of the files.
The buffers used for blocks are perfectly suited for this.
Not to mention that a 16 by 64 block of code is a perfect
match for Forth, for a multi purpose library.
Personally I love the editing environment screens afford - small,
modular, no information overload.
You need video mode 3 set by BIOS call 10.
To my surprise dosbox supports direct screen access, e.g.
42 B0000 C!
puts a B in the upper left corner.
This allows a graphics editor based on the ^E ^S ^D ^X diamond pattern,
etc. ^Y removes a line but it stack up outside the 16 lines and
can be put any where with ^U etc.
This is part of my the library of ciforth, but it only runs on
the 16 version of ciforth (mina).
(this was first implemented on my Osborne, a CP/M system).

Groetjes Albert
--
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.
dxf
2024-12-11 13:27:05 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
Post by dxf
Post by a***@spenarnc.xs4all.nl
Post by Hans Bezemer
Post by Hans Bezemer
...
Congratulations! It's nice to see such compilers remain maintained and
relevant!
Thanks. Not sure about relevant :) It's nevertheless interesting to see the odd
user get some use out of it. Even more of an eyebrow raiser is when they go along
with archaisms such as screens for source.
http://youtu.be/kYvYu5AfSxg
When I was forced to do line by line including of source,
I needed buffers to hold a piece of the files.
The buffers used for blocks are perfectly suited for this.
Not to mention that a 16 by 64 block of code is a perfect
match for Forth, for a multi purpose library.
Personally I love the editing environment screens afford - small,
modular, no information overload.
You need video mode 3 set by BIOS call 10.
To my surprise dosbox supports direct screen access, e.g.
42 B0000 C!
puts a B in the upper left corner.
This allows a graphics editor based on the ^E ^S ^D ^X diamond pattern,
etc. ^Y removes a line but it stack up outside the 16 lines and
can be put any where with ^U etc.
This is part of my the library of ciforth, but it only runs on
the 16 version of ciforth (mina).
(this was first implemented on my Osborne, a CP/M system).
DOSBOX does a good job supporting the old video modes. I was gratified
to find the Lorenzian Waterwheel application I had ported still worked.
See WW4TH.ZIP at:

https://drive.google.com/drive/folders/1kh2WcPUc3hQpLcz7TQ-YQiowrozvxfGw
John
2024-12-23 23:41:03 UTC
Permalink
Post by Hans Bezemer
Post by dxf
DX-Forth is a Forth language compiler and development system
for MS-DOS and CP/M-80 operating systems.  It is intended to
be a complete, easy to use, programming tool for the creation
of turnkey applications.
v4.57  2024-12-08
+ added  - removed  * fixed  ! changed  = updated
+  (NUMBER) \CHAR CSKIP "
!  INTEGER moved to TOOLS
!  DOSLIB: strings, parsing, files
DXCPM457.ZIP (CP/M-80)
DXDOS457.ZIP (MS-DOS)
https://drive.google.com/drive/folders/1kh2WcPUc3hQpLcz7TQ-YQiowrozvxfGw
Congratulations! It's nice to see such compilers remain maintained and
relevant!
Hans Bezemer
Very impressive. Nice to see CP/M supported.
Will it run on later versions of DOS past 2.x ?

-John
dxf
2024-12-24 02:28:49 UTC
Permalink
...
Very impressive.  Nice to see CP/M supported.
Will it run on later versions of DOS past 2.x ?
Yes - I should have been more clear. For a long time it was developed
under Win98 in a DOS window. 2.x support is probably the tentative one.
John
2024-12-25 04:06:05 UTC
Permalink
Post by dxf
...
Very impressive.  Nice to see CP/M supported.
Will it run on later versions of DOS past 2.x ?
Yes - I should have been more clear. For a long time it was developed
under Win98 in a DOS window. 2.x support is probably the tentative one.
Also, I seem to have some trouble with the floating point.
Keep getting f-stack error messages, which the manual says are
under/over flows.


1 9 / <return> returns a zero, not the expected 0.11111

So, I'm guessing the F* (etc.) are the floating point arithmetic.
3 5 F* <return> however gives an "f-stack" error. 15 is an overflow?

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

Maybe I'm not doing it right, I'm just doing what's intuitive to me.
And yes, I'm running FORTH-F. This is the DOS version.
Please help a wayward user....

-J
dxf
2024-12-25 08:09:36 UTC
Permalink
Post by John
...
Also, I seem to have some trouble with the floating point.
Keep getting f-stack error messages, which the manual says are under/over flows.
1 9 / <return>  returns a zero, not the expected 0.11111
So, I'm guessing the F* (etc.) are the floating point arithmetic.
3 5 F* <return>  however gives an "f-stack" error. 15 is an overflow?
Reals are entered with an 'e' thus:

3e 5e f* f. 15. ok

The forth interpreter must be in DECIMAL for this to work.
Post by John
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. Integers
take the form:

Singles: 1 -2 3
Doubles: 1. -2. 3.

Doubles have their own operators D+ D* D. etc. There are also mixed operators
e.g. UM* that takes two unsigned singles and leaves an unsigned double.
Post by John
Maybe I'm not doing it right, I'm just doing what's intuitive to me.
And yes, I'm running FORTH-F.  This is the DOS version.
Please help a wayward user....
Since Forth is rather different it has had to develop its own conventions.
A bit of practice and it will become second nature!

HTH
Anton Ertl
2024-12-25 11:36:16 UTC
Permalink
Post by dxf
Post by John
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
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
minforth
2024-12-25 13:41:13 UTC
Permalink
My way: if the double number wordset is not included (i.e. practically
always) any number with a decimal point is recognized as fp number. Very
handy.
dxf
2024-12-25 23:07:42 UTC
Permalink
Post by minforth
My way: if the double number wordset is not included (i.e. practically
always) any number with a decimal point is recognized as fp number. Very
handy.
So it's one or the other and your comment suggests doubles are preferred.
This relates to the forth interpreter and from my observation there's been
little historical demand '1.34' be recognized as a float. A curiosity it
certainly is as it's so unusual.
Paul Rubin
2024-12-25 23:28:08 UTC
Permalink
there's been little historical demand '1.34' be recognized as a float.
It's a mistake I make all the time, but I figure it's one of Forth's
frozen oddities. In a non-ANS Forth, I'd probably make 1.34 a float and
use some other scheme for literal doubles.
dxf
2024-12-26 01:52:28 UTC
Permalink
Post by Paul Rubin
there's been little historical demand '1.34' be recognized as a float.
It's a mistake I make all the time, but I figure it's one of Forth's
frozen oddities. In a non-ANS Forth, I'd probably make 1.34 a float and
use some other scheme for literal doubles.
Embedded punctuation in doubles was something I was never happy with
(misleading, can make a typo and still be accepted). So when ANS limited
it to one decimal point at the end I was rather relieved.
Paul Rubin
2024-12-26 18:48:24 UTC
Permalink
Post by dxf
Embedded punctuation in doubles was something I was never happy with
(misleading, can make a typo and still be accepted). So when ANS limited
it to one decimal point at the end I was rather relieved.
I'm having trouble finding the place in ANS 94[0] or Forth 2012[1] where
any of this is specified. That surprises me. Particularly, 3.4.1.3
Text interpreter input number conversion doesn't discuss the matter.

[0] https://www.taygeta.com/forth/dpans.html
[1] https://forth-standard.org/standard/words
minforth
2024-12-26 19:08:25 UTC
Permalink
Number conversions in Forth are shock full of
old ballast, justified by legacy code concerns.
Maybe it would be easier to get rid of such stuff
(e.g. exotic formats in >FLOAT) and just define
a new Legacy-Code Wordset.
dxf
2024-12-26 23:49:47 UTC
Permalink
Post by minforth
Number conversions in Forth are shock full of
old ballast, justified by legacy code concerns.
Maybe it would be easier to get rid of such stuff
(e.g. exotic formats in >FLOAT) and just define
a new Legacy-Code Wordset.
AFAIR the 'exotic formats' in >FLOAT were nothing special.
Excluding them could well result in more code which would
be a perverse outcome.
Anton Ertl
2024-12-26 21:55:18 UTC
Permalink
Post by Paul Rubin
I'm having trouble finding the place in ANS 94[0] or Forth 2012[1] where
any of this is specified. That surprises me. Particularly, 3.4.1.3
Text interpreter input number conversion doesn't discuss the matter.
<https://forth-standard.org/standard/double#subsection.8.3.1>

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
dxf
2024-12-27 00:25:26 UTC
Permalink
Post by Anton Ertl
Post by Paul Rubin
I'm having trouble finding the place in ANS 94[0] or Forth 2012[1] where
any of this is specified. That surprises me. Particularly, 3.4.1.3
Text interpreter input number conversion doesn't discuss the matter.
<https://forth-standard.org/standard/double#subsection.8.3.1>
AFAIR Forth-83 offered no such method, though individual systems likely did.
Paul Rubin
2024-12-27 00:41:37 UTC
Permalink
Post by Anton Ertl
<https://forth-standard.org/standard/double#subsection.8.3.1>
Aha, thanks. Similarly 8.3.2 for DPANS94. Oddly, in gforth, "123.45"
pushes 12345 0. I can understand "123." is a number (123) followed by a
decimal point, but I'd expect the 45 to either be invalid or another
number, giving 123 0 45.
mhx
2024-12-27 01:26:54 UTC
Permalink
Post by Paul Rubin
Post by Anton Ertl
<https://forth-standard.org/standard/double#subsection.8.3.1>
Aha, thanks. Similarly 8.3.2 for DPANS94. Oddly, in gforth, "123.45"
pushes 12345 0. I can understand "123." is a number (123) followed by a
decimal point, but I'd expect the 45 to either be invalid or another
number, giving 123 0 45.
There is a USER variable, DPL, that tracks the Location of the Decimal
Point.
The intention can therefore be reconstructed.

-marcel
minforth
2024-12-27 10:26:04 UTC
Permalink
FWIW, probably nothing, there is no mention of DPL in the standard.
a***@spenarnc.xs4all.nl
2024-12-27 11:17:14 UTC
Permalink
Post by minforth
FWIW, probably nothing, there is no mention of DPL in the standard.
It is one of those traditions.
iforth, gforth, swiftforth, many figforth's, ciforth, mpeforth have it.

Groetjes Albert
--
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.
minforth
2024-12-27 15:46:11 UTC
Permalink
Yes ... those traditions ... as was COMPILE from earlier Forths.
Banned because it was ambiguous.
Luckily we now have POSTPONE which makes everything clearer.
But sorry, that was an inappropriate remark ...

Back to double numbers: with the new recogniser concept
recognition of different double number formats is laid into
the hand of users, and such standardisation becomes more of a
recommendation.
a***@spenarnc.xs4all.nl
2024-12-28 12:09:26 UTC
Permalink
Post by minforth
Yes ... those traditions ... as was COMPILE from earlier Forths.
Banned because it was ambiguous.
Luckily we now have POSTPONE which makes everything clearer.
But sorry, that was an inappropriate remark ...
Back to double numbers: with the new recogniser concept
recognition of different double number formats is laid into
the hand of users, and such standardisation becomes more of a
recommendation.
It could easily be in ciforth using PREFIX, that adds two lines
to the kernel, and the word itself. Also it observes search order.
The "recognizer" way is more complicated, and - dare I say -
harder to use.
--
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.
Anton Ertl
2024-12-31 21:51:35 UTC
Permalink
Post by Paul Rubin
Post by Anton Ertl
<https://forth-standard.org/standard/double#subsection.8.3.1>
Aha, thanks. Similarly 8.3.2 for DPANS94. Oddly, in gforth, "123.45"
pushes 12345 0. I can understand "123." is a number (123) followed by a
decimal point, but I'd expect the 45 to either be invalid or another
number, giving 123 0 45.
Traditionally, Forth has used the syntax 123.45 for fixed-point
numbers. You get the same number on the stack as with the standard
"12345.", and in addition, the (user) variable DPL is set to indicate
the position of the decimal point. I have no idea how this crude way
was used in practice, but in any case, Gforth implements this feature.

The Forth-94 standardizers were apparently less convinced, so they
standardized neither numbers with an embedded decimal point, nor DPL.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
dxf
2025-01-01 00:45:27 UTC
Permalink
Post by Anton Ertl
Post by Paul Rubin
Post by Anton Ertl
<https://forth-standard.org/standard/double#subsection.8.3.1>
Aha, thanks. Similarly 8.3.2 for DPANS94. Oddly, in gforth, "123.45"
pushes 12345 0. I can understand "123." is a number (123) followed by a
decimal point, but I'd expect the 45 to either be invalid or another
number, giving 123 0 45.
Traditionally, Forth has used the syntax 123.45 for fixed-point
numbers. You get the same number on the stack as with the standard
"12345.", and in addition, the (user) variable DPL is set to indicate
the position of the decimal point. I have no idea how this crude way
was used in practice, but in any case, Gforth implements this feature.
It's possible this came from Kitt Peak Forth (on which Forth-77 was based)
and picked up by Fig-forth. 'Starting Forth' (Forth Inc) supported
'embedded punctuation' - a range of characters including / # etc to simulate
various formatting e.g. time and date.
Post by Anton Ertl
The Forth-94 standardizers were apparently less convinced, so they
standardized neither numbers with an embedded decimal point, nor DPL.
To support DPL I have >NUMBER increment it for every digit successfully
converted. While most systems today have DPL (?) usage is probably too
diverse to standardize.
Bernd Linsel
2025-01-01 03:42:55 UTC
Permalink
Post by dxf
To support DPL I have >NUMBER increment it for every digit successfully
converted. While most systems today have DPL (?) usage is probably too
diverse to standardize.
It's documented in F83 Annex B (Uncontrolled Reference Words):


DPL -- addr U "d-p-l"
A variable containing the number of places after the
fractional point for input conversion.

It's usually implemented that DPL is reset to -1 when entering >NUMBER,
each successful digit conversion increments it only if it is >= 0, and
the first decimal separator encountered changes it from -1 to 0.
--
Bernd Linsel
dxf
2025-01-01 05:17:42 UTC
Permalink
Post by dxf
To support DPL I have >NUMBER increment it for every digit successfully
converted.  While most systems today have DPL (?) usage is probably too
diverse to standardize.
Those being mostly words from Kitt Peak Forth.
      DPL          -- addr                       U              "d-p-l"
           A variable containing the number of places after the
           fractional point for input conversion.
It's usually implemented that DPL is reset to -1 when entering >NUMBER,
each successful digit conversion increments it only if it is >= 0, and the first decimal separator encountered changes it from -1 to 0.
Yes, in Fig-Forth. In Swiftforth DPL is just a flag. Now you've got me
wondering why Fig does the 'test before increment' and I left it out ...
dxf
2025-01-01 07:58:44 UTC
Permalink
Post by dxf
Post by dxf
To support DPL I have >NUMBER increment it for every digit successfully
converted.  While most systems today have DPL (?) usage is probably too
diverse to standardize.
Those being mostly words from Kitt Peak Forth.
      DPL          -- addr                       U              "d-p-l"
           A variable containing the number of places after the
           fractional point for input conversion.
It's usually implemented that DPL is reset to -1 when entering >NUMBER,
each successful digit conversion increments it only if it is >= 0, and the first decimal separator encountered changes it from -1 to 0.
Yes, in Fig-Forth. In Swiftforth DPL is just a flag. Now you've got me
wondering why Fig does the 'test before increment' and I left it out ...
Ok, the reason I left out the pre-increment test was likely generality.
In DX-Forth the DPL increment feature is ignored. Since my doubles are
strictly ANS, DPL can only be -1 or 0.
Anton Ertl
2025-01-01 11:47:16 UTC
Permalink
Post by dxf
Post by Bernd Linsel
It's usually implemented that DPL is reset to -1 when entering >NUMBER,
each successful digit conversion increments it only if it is >= 0, and the first decimal separator encountered changes it from -1 to 0.
Yes, in Fig-Forth. In Swiftforth DPL is just a flag.
SwiftForth x64-Linux 4.0.0-RC89 15-Jul-2024
1 dpl ? -1023 ok
1.234 dpl ? 3 ok
12 dpl ? -1022 ok

Apparently SwiftForth counts every digit starting with -1024, and "."
setting the count to 0. So for doubles the behaviour is the same as
that of Gforth, and testing for dpl @ 0< identifies singles on both
systems. lxf and VFX behave like Gforth.

So systems that implement DPL implement it similarly enough that
programs can determine the number of digits after the decimal point.

But does anybody actually make use of DPL? I have not seen a single
use, ever. Is it just some feature that someone thought up and
implemented, and we all continued to implement it because we could and
it was traditional?

If there has been a use at some time, is there still? I have not seen
complaints about the non-standardization of DPL and the
only-terminating decimal point in Forth-94 or Forth-2012.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
HenryHH
2025-01-01 12:48:01 UTC
Permalink
Post by Anton Ertl
But does anybody actually make use of DPL? I have not seen a single
use, ever. Is it just some feature that someone thought up and
implemented, and we all continued to implement it because we could and
it was traditional?
I find DPL very useful and have used it all the time for many years.

This variable can replace a floating point package in cases where only
basic math operations (+, -, *, /) are required. I have used fixed point
math
in applications that control measurement systems in a physics
laboratory.

Please have a look at my fixed point math package on theForthNet.
http://theforth.net/package/fixed

Henry
dxf
2025-01-01 13:20:53 UTC
Permalink
Post by Anton Ertl
Post by dxf
Post by Bernd Linsel
It's usually implemented that DPL is reset to -1 when entering >NUMBER,
each successful digit conversion increments it only if it is >= 0, and the first decimal separator encountered changes it from -1 to 0.
Yes, in Fig-Forth. In Swiftforth DPL is just a flag.
SwiftForth x64-Linux 4.0.0-RC89 15-Jul-2024
1 dpl ? -1023 ok
1.234 dpl ? 3 ok
12 dpl ? -1022 ok
My bad. >NUMBER increments DPL but how/when appears to vary with implementation.
Also Kitt Peak Forth (1979) DPL is for output - not input!
Post by Anton Ertl
Apparently SwiftForth counts every digit starting with -1024, and "."
setting the count to 0. So for doubles the behaviour is the same as
systems. lxf and VFX behave like Gforth.
So systems that implement DPL implement it similarly enough that
programs can determine the number of digits after the decimal point.
But does anybody actually make use of DPL? I have not seen a single
use, ever. Is it just some feature that someone thought up and
implemented, and we all continued to implement it because we could and
it was traditional?
Since >NUMBER (and previous incarnations) all increment DPL such use must
have been originally envisioned.
Post by Anton Ertl
If there has been a use at some time, is there still? I have not seen
complaints about the non-standardization of DPL and the
only-terminating decimal point in Forth-94 or Forth-2012.
Pulling DPL out of systems that currently use it might result in complaints.
mhx
2025-01-01 13:47:29 UTC
Permalink
I have used DPL sporadically:

Searching for: DPL
D:\dfwforth\examples\eforth\eforth.frt(420): VARIABLE DPL ( numeric
input
D:\dfwforth\examples\eforth\eforth.frt(641): >R >R D# 0 DUP R> R> D#
-1 DPL
D:\dfwforth\examples\eforth\eforth.frt(645): THEN D# 1 - DPL ! CHAR+
DPL @
D:\dfwforth\examples\eforth\eforth.frt(797): IF DPL @ 0< ( single? )
D:\dfwforth\examples\eforth\eforth.frt(891): IF DPL @ 0<
D:\dfwforth\examples\eforth\emeta.frt(216): : #O ( d -- n | d ) DPL @ 0<
IF
D:\dfwforth\examples\eforth\emeta.frt(217): : #I ( n | d ) DPL @ 0< IF
DROP [I]
D:\dfwforth\examples\graphics\readps.frt(145): : inch DPL @ 0> IF
D:\dfwforth\examples\graphics\readps.frt(146): Xmax gain * #10 DPL @ 0
MAX
D:\dfwforth\examples\sod64\cross.frt(377): VARIABLE DPL
D:\dfwforth\examples\sod64\cross.frt(380): -1 DPL !
D:\dfwforth\examples\sod64\cross.frt(390): DUP IF OVER C@ '.' = IF 1
/STRING
D:\dfwforth\examples\sod64\cross.frt(415): DPL @ -1 <> ABORT" cross ::
128 bit
D:\dfwforth\examples\sod64\kernel.frt(513): VARIABLE DPL ( -- a-addr )
D:\dfwforth\examples\sod64\kernel.frt(987): \G f is true if and only if
the
D:\dfwforth\examples\sod64\kernel.frt(990): -1 DPL !
D:\dfwforth\examples\sod64\kernel.frt(1000): DUP IF OVER C@ #46 = IF 1
- DUP
D:\dfwforth\include\ix86asm.frt(176): DPL @ -1 = 0= \ double word?
D:\dfwforth\include\ix86asm.frt(178): -1 DPL !
D:\dfwforth\include\ix86asm.frt(197): DPL @ -1 = 0= \ double word?
D:\dfwforth\include\ix86asm.frt(199): -1 DPL !
D:\dfwforth\include\ix86asm.frt(247): : d# 4033 -1 DPL !
D:\dfwforth\include\ix86asm.frt(248): : d#) 4050 CLEAR double -1 DPL ! ;
D:\dfwforth\include\ix86asm.frt(249): : sd#) 4060 CLEAR double -1 DPL !
;
Found 25 occurrence(s) in 6 file(s), 35346 ms

Given it is in the assembler and the postscript plotter, I would not be
a happy customer when it proved to be lacking.

-marcel
a***@spenarnc.xs4all.nl
2025-01-01 15:07:57 UTC
Permalink
<SNIPPED examples of assemblers>
Post by mhx
Found 25 occurrence(s) in 6 file(s), 35346 ms
Given it is in the assembler and the postscript plotter, I would not be
a happy customer when it proved to be lacking.
Given that the use of DPL is system dependant, that is not
consequential. Or would you claim that all this source
is strictly ISO-compliant?

I have used DPL only in the following way:
it is initialised as null pointer. After parsing it points
in the input stream to a decimal point if any.
Then the number interpreters can use it every which way.
So the concept is useful, but not so much amenable to
standardisation.
Post by mhx
-marcel
Groetjes Albert
--
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.
dxf
2025-01-01 22:19:53 UTC
Permalink
Here's a routine from 2003 reworked for clarity. While DPL could have
been avoided it simplified things and perhaps that's its value.

: ?BAD ( n -- ) abort" bad" ;

: /NUM ( a u -- ud a' u' ) dpl off 0 0 2swap >number ;

\ Convert inch (x.yyy) to mils
: /FLOAT ( a u -- mils )
/num 2swap drop >r ( whole) dup if
over c@ [char] . - ?bad 1 /string
then
3 min /num nip ?bad drop ( frac)
( scale to 0-999 )
1 3 dpl @ - 0 ?do 10 * loop *
r> 1000 * ( scale whole )
+ ; ( add frac )

: t bl word count /float u. ;

t 1.234
t 1.2
t 1.2345
t 1
a***@spenarnc.xs4all.nl
2024-12-27 11:04:26 UTC
Permalink
Post by Anton Ertl
Post by Paul Rubin
I'm having trouble finding the place in ANS 94[0] or Forth 2012[1] where
any of this is specified. That surprises me. Particularly, 3.4.1.3
Text interpreter input number conversion doesn't discuss the matter.
<https://forth-standard.org/standard/double#subsection.8.3.1>
(In my old '92 copy it is in a subsection of 8.3 )
A forth that interprets e.g. 3.14 as a floating point number
is as non-standard as a Forth that interprets 3.14 is a double.
Think about it!

How would a proposal like this fare:
"
A double number is only recognized as it ends *and starts*
with a period.
Recognizing a double if it ends only in a period becomes
obsolescent.
"
.314. : double
3.14 : fp
.314E1 : fp
Post by Anton Ertl
- anton
Groetjes Albert
--
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.
dxf
2024-12-27 23:43:32 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
Post by Anton Ertl
Post by Paul Rubin
I'm having trouble finding the place in ANS 94[0] or Forth 2012[1] where
any of this is specified. That surprises me. Particularly, 3.4.1.3
Text interpreter input number conversion doesn't discuss the matter.
<https://forth-standard.org/standard/double#subsection.8.3.1>
(In my old '92 copy it is in a subsection of 8.3 )
A forth that interprets e.g. 3.14 as a floating point number
is as non-standard as a Forth that interprets 3.14 is a double.
Think about it!
"
A double number is only recognized as it ends *and starts*
with a period.
Recognizing a double if it ends only in a period becomes
obsolescent.
"
.314. : double
3.14 : fp
.314E1 : fp
It's not orthodoxy. Are folks more - or less - likely to go it alone
today than 30 years ago when proposals like this were first made?
Anton Ertl
2024-12-31 21:57:55 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
A forth that interprets e.g. 3.14 as a floating point number
is as non-standard as a Forth that interprets 3.14 is a double.
Forth-94 and Forth-2012 do not standardize recognizing 3.14, so
standard systems are allowed to deal with "3.14" as they deem useful.
The possible options include recognizing "3.14" as a double-cell
integer, as a FP number, or not recognizing "3.14" and producing an
error message.

However, I think that recognizing "314." as a double-cell integer (as
required by these standards), but recognizing "3.14" as an FP number
is even more confusing and error prone than recognizing both as a
double-cell integer.
Post by a***@spenarnc.xs4all.nl
"
A double number is only recognized as it ends *and starts*
with a period.
Existing practice? What's wrong with "#314."?
Post by a***@spenarnc.xs4all.nl
Recognizing a double if it ends only in a period becomes
obsolescent.
"
That part may have an easier time.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
a***@spenarnc.xs4all.nl
2025-01-02 14:21:46 UTC
Permalink
Post by Anton Ertl
Post by a***@spenarnc.xs4all.nl
A forth that interprets e.g. 3.14 as a floating point number
is as non-standard as a Forth that interprets 3.14 is a double.
Forth-94 and Forth-2012 do not standardize recognizing 3.14, so
standard systems are allowed to deal with "3.14" as they deem useful.
The possible options include recognizing "3.14" as a double-cell
integer, as a FP number, or not recognizing "3.14" and producing an
error message.
However, I think that recognizing "314." as a double-cell integer (as
required by these standards), but recognizing "3.14" as an FP number
is even more confusing and error prone than recognizing both as a
double-cell integer.
Post by a***@spenarnc.xs4all.nl
"
A double number is only recognized as it ends *and starts*
with a period.
Existing practice? What's wrong with "#314."?
There is no existing practice, of course.
How hard could it be to get used to ".314. as long as you use
.314. ?
The confusion between 31E0 (hex) 31E0 (fp) 3.10 is another
roadblock to Forth newbies.
And then fixed point. That adds to the confusion.
I'd rather introduce a prefix ("recognizer") of some sort,
to make sure that the program doesn't compile instead of
strange behaviour.
Post by Anton Ertl
Post by a***@spenarnc.xs4all.nl
Recognizing a double if it ends only in a period becomes
obsolescent.
"
That part may have an easier time.
I meant
Recognizing a double if it contains one single period at the end
becomes obsolescent.
Post by Anton Ertl
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
--
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.
Anton Ertl
2025-01-02 15:51:11 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
The confusion between 31E0 (hex) 31E0 (fp) 3.10 is another
roadblock to Forth newbies.
Certainly, especially the latter. The hex problem can be eliminated
by always keeping the BASE as DECIMAL, and writing hex numbers as
$31E0. The 3.10 tradition and the 31. standard can be addressed with
a variation of your statement:

Recognizing a double if it contains no number prefix and one single
period at the end is obsolescent.

One step later a standard Forth system could recognize 3.10 as well as
31. and 31e as FP values, #31. as a double-cell integer, and $31e
as a single-cell integer.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
a***@spenarnc.xs4all.nl
2025-01-03 14:37:14 UTC
Permalink
Post by Anton Ertl
Post by a***@spenarnc.xs4all.nl
The confusion between 31E0 (hex) 31E0 (fp) 3.10 is another
roadblock to Forth newbies.
Certainly, especially the latter. The hex problem can be eliminated
by always keeping the BASE as DECIMAL, and writing hex numbers as
$31E0. The 3.10 tradition and the 31. standard can be addressed with
Recognizing a double if it contains no number prefix and one single
period at the end is obsolescent.
One step later a standard Forth system could recognize 3.10 as well as
31. and 31e as FP values, #31. as a double-cell integer, and $31e
as a single-cell integer.
One step further is to use 0x for hex values, and free $ for
environment strings.
This scheme has so much going for it that I tend to give up
the advantage to represent floating points exactly in hex. 1]
Then probably one can forget BASE DECIMAL and ban double numbers to
an obscure region of a library.

1] This is not easy. I have been in many projects where floating points
were transferred in text, loosing precision. But of course parameters
in oil drill samples need not 5 decimal places.
Post by Anton Ertl
- anton
Groetjes Albert
--
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.
Anton Ertl
2025-01-03 16:00:18 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
One step further is to use 0x for hex values, and free $ for
environment strings.
Forth systems can use 0x as hex prefix already, and in 2007 I checked
several systems <http://www.forth200x.org/number-prefixes.html>: PFE,
Gforth 0.6.9, Win32Forth (4.x and 6.x), and VFX Forth understood 0x10
as well as 0X10; iForth, bigForth, SwiftForth, and lxf did not.

Someone would need to make a proposal for making the $ prefix for hex
numbers obsolescent as a first step towards destandardization.
Meanwhile, Gforth has a recognizer for environment variables:

${HOME} type

prints "/home/anton".
Post by a***@spenarnc.xs4all.nl
Then probably one can forget BASE DECIMAL
We would need to standardize at least BASE-EXECUTE to get rid of
dealing with BASE for producing output.
Post by a***@spenarnc.xs4all.nl
1] This is not easy. I have been in many projects where floating points
were transferred in text, loosing precision.
Floating-point numbers can be losslessly converted from binary to
decimal representation and back, with losslessly meaning that you get
the same binary FP number after one cycle, and for

decimal1 -> binary1 -> decimal2 -> binary2 -> decimal3

binary1 and binary2 are the same bit pattern, and decimal2 and
decimal3 are the same string.

However, doing it for hex is admittedly much simpler. But then, if
the issue is just to get the number from one system to the next
without having to deal with byte order and the like, you can also do
(on a system with 64-bit cells):

variable x

1.23e x df! x @ . \ prints 4608218246714312622 on Gforth

The output is an exact representation of the bit pattern. Now on the
next system you can:

variable x 4608218246714312622 x ! x df@ f.

I tried this on iForth, SwiftForth and VFX, and it worked on all of
them, outputting "1.23", sometimes with trailing zeroes.

The conversion of "1.23e" by the Forth text interpreter and of the end
result by F. may be less precise than you would like, though.
Post by a***@spenarnc.xs4all.nl
But of course parameters
in oil drill samples need not 5 decimal places.
When writing general-purpose code, we do not know the needed accuracy,
so if it is possible to produce an "exact" result, we should do so.

The definition of "exact" is interesting in this case. E.g., there is
no exact representation of 1.23 as binary FP number, so we generally
go for the binary FP number that is closest to the input number.
Conversely, the binary64 number with the bit pattern
4608218246714312622 can be represented exactly in decimal as
1.229999999999999982236431605997495353221893310546875, but we may
prefer to output the shortest string that, when converted back to
binary64, produces the same binary64 value (in this case "1.23").

Back to hex FP, if we go there at all, we might want to go with the
string format used in C source code: 0xhhhh.hhhp-ddd where h is a hex
digit and d is a decimal digit.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
minforth
2025-01-04 10:03:27 UTC
Permalink
While at it, nailing Forth's foot to the IEEE-754 standard
floor may have been premature. BFLOAT16 or Nvidia's TensorFloat
(and other fp-formats) are becoming increasingly popular.
a***@spenarnc.xs4all.nl
2025-01-04 16:09:43 UTC
Permalink
Post by Anton Ertl
Post by a***@spenarnc.xs4all.nl
One step further is to use 0x for hex values, and free $ for
environment strings.
Forth systems can use 0x as hex prefix already, and in 2007 I checked
several systems <http://www.forth200x.org/number-prefixes.html>: PFE,
Gforth 0.6.9, Win32Forth (4.x and 6.x), and VFX Forth understood 0x10
as well as 0X10; iForth, bigForth, SwiftForth, and lxf did not.
Someone would need to make a proposal for making the $ prefix for hex
numbers obsolescent as a first step towards destandardization.
${HOME} type
prints "/home/anton".
In ciforth
WANT $-PREFIX
adds `` # $ 0x '' to the minimal search order, because they define
numbers.

{ ONLY WORDS PREVIOUS } EXECUTE
' & ^ 0 1 2 3 4 5 6 7 8 9 A B C
D E F - + " FORTH $ 0x # OK
^ ^ ^
The temporary executable thingy is needed, because after `ONLY , `WORDS
is not found. `PREVIOUS restores this.
A word "GET-ENV" is in order, e.g.
"HOME" GET-ENV TYPE
/home/albert OK
Now defining $ is easy, but it is preferable to get rid of the $ word first.
'$ HIDDEN
OK
: $ NAME GET-ENV ; PREFIX
OK
$HOME TYPE
/home/albert OK

Or your proposed syntax:
: ${ &} PARSE GET-ENV ; PREFIX

${HOME} TYPE
/home/albert OK

These words land in the CURRENT wordlist not in `ONLY :
WORDS
ONLY ENVIRONMENT NOOP ....
.... ENV0 SHIFT-ARGS (MENV) GET-ENV ${
OK ^
Post by Anton Ertl
- anton
Groetjes Albert
--
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.
a***@spenarnc.xs4all.nl
2025-01-02 14:07:34 UTC
Permalink
Post by dxf
Post by Paul Rubin
there's been little historical demand '1.34' be recognized as a float.
It's a mistake I make all the time, but I figure it's one of Forth's
frozen oddities. In a non-ANS Forth, I'd probably make 1.34 a float and
use some other scheme for literal doubles.
Embedded punctuation in doubles was something I was never happy with
(misleading, can make a typo and still be accepted). So when ANS limited
it to one decimal point at the end I was rather relieved.
In the ciforth model it is allowed to have , in numbers.
The ascii code for &, is low, so this doesn't interfere with
64 base hex numbers, and even not with 64 base floating point,
as long as you switch the exponent sign to &_.

Chuck Moore, as soon as 32 bits computers came on the scene,
proposed to ditch double numbers altogether.
I have made an educative forth (yourforth) similar to jonesforth.
There I could avoid the complication of double numbers.

P.S. I like double precision 64 bit numbers, but I like number theory.

Groetjes Albert
--
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.
dxf
2025-01-03 03:35:13 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
...
Chuck Moore, as soon as 32 bits computers came on the scene,
proposed to ditch double numbers altogether.
I have made an educative forth (yourforth) similar to jonesforth.
There I could avoid the complication of double numbers.
P.S. I like double precision 64 bit numbers, but I like number theory.
Well, I consider mixed-math to be genius :) Was it a Forth first -
or it pre-existed in some language/system?
minforth
2025-01-03 07:56:48 UTC
Permalink
Old hat. The PDP-11 already had mixed multiplication and division.
dxf
2025-01-03 09:15:32 UTC
Permalink
Post by minforth
Old hat. The PDP-11 already had mixed multiplication and division.
That explains it.

"Chuck Moore has told me that the PDP-11 had a lot of influence on Forth."

(http://www.stackosaurus.com/figforth.html)
Anton Ertl
2025-01-03 09:59:20 UTC
Permalink
Post by dxf
Well, I consider mixed-math to be genius :) Was it a Forth first -
or it pre-existed in some language/system?
I am not aware of any other non-assembly language that supports
mixed-width math. Some other programming languages have multiple
integer or FP widths, but they tend to define their operations as
first converting to a common width, and then producing a result of the
same width. This can be used to specify widening operations, e.g., as
follows (in C):

int64_t widening_mul(int32_t a, int32_t b)
{
return a * (int64_t)b;
}

but the compiler has to do extra work to recognize that this is a
widening multiplication (rather than first sign-extending the operands
and then performing a 64bit*64bit->64bit multiplication).

And for division there is no way to specify the likes of UM/MOD or
SM/REM in C such that it can be implemented with just the DIV or IDIV
instruction (plus maybe register-register moves) of IA-32 or AMD64.

Mixed-width multiplication and division is a natural outcome of
implementing multiplication and division using repeated addition,
subtraction and shifting, and of course the first PDP-11
implementation, the 8086, 68000 and MIPS R2000, which implemented
these operations internally in that way, provide mixed-width
instructions for them.

More recent CPUs use different implementation techniques, so recent
architectures tend not to provide mixed-width division instructions.
They tend to have support for mixed-width multiplication (but usually
split that into two instructions), probably because it's important for
implementing wide multiplication, which is important for cryptography.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
minforth
2025-01-03 11:50:08 UTC
Permalink
Post by Anton Ertl
More recent CPUs use different implementation techniques, so recent
architectures tend not to provide mixed-width division instructions.
They tend to have support for mixed-width multiplication (but usually
split that into two instructions), probably because it's important for
implementing wide multiplication, which is important for cryptography.
Assembler programming for such applications is a nightmare.
I'd rather use libtommath/crypt et al for that:
https://github.com/libtom

(cryptocurrency miners may have a different opinion...)
Anton Ertl
2024-12-26 08:33:49 UTC
Permalink
Post by Paul Rubin
there's been little historical demand '1.34' be recognized as a float.
Depends on how far back in history you go. I have seen quite a few
puzzled questions by people new to Forth who were confused why
something like

1.23 4.56 f+ f.

does not work as they expect. This problem is increased by the
requirement in the standard that

123e f.

prints "123." (maybe with trailing zeros) rather than something that,
when copied and pasted as Forth input, reproduces that number.

There is a reason why Gforth produces warnings when you write numbers
in that way (and that includes writing them as "123.").
Post by Paul Rubin
It's a mistake I make all the time, but I figure it's one of Forth's
frozen oddities.
It's a backwards compatibility problem, yes, but I see a way to melt
it, see below.
Post by Paul Rubin
In a non-ANS Forth, I'd probably make 1.34 a float and
use some other scheme for literal doubles.
We have discussed this maybe a decade ago in a Forth200x meeting, and
someone pointed out that we already have that other scheme: For
doubles with decimal base, use

#123.

Similarly for hex and binary base. Doubles in other bases are
extremely rare (I don't think I ever encountered one).

With that in place, the next step in the melting process would be to
make the "123." syntax obsolescent. And then, one standard version
later, destandardize this syntax. Then systems would be free to
interpret "123." as FP number, and I expect that many would switch. I
am less optimistic about standardizing the "123." syntax as indicating
FP, because I expect that there will be systems that stick with "123."
being interpreted as double-cell integer for backward-compatibility
reasons, or to honour the prophet.

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
dxf
2024-12-26 09:23:59 UTC
Permalink
Post by Anton Ertl
there's been little historical demand '1.34' be recognized as a float.
Depends on how far back in history you go. I have seen quite a few
puzzled questions by people new to Forth who were confused why
something like
1.23 4.56 f+ f.
does not work as they expect.
And there's never been enough support standard-wise to make that work.
Post by Anton Ertl
This problem is increased by the
requirement in the standard that
123e f.
prints "123." (maybe with trailing zeros) rather than something that,
when copied and pasted as Forth input, reproduces that number.
Ditto. The only person I'm aware to consistently raise the copy/paste
issue is you. Mitch Bradley is a fan of parsing words like F# 123 but
he got no support. Folks wanted the interpreter to expressly handle
floats hence the 'E' syntax. Can't please everyone?
mhx
2024-12-26 08:24:15 UTC
Permalink
Post by dxf
So it's one or the other and your comment suggests doubles are
preferred.
This relates to the forth interpreter and from my observation there's
been little historical demand '1.34' be recognized as a float.
A curiosity it certainly is as it's so unusual.
Not for readers of 'Starting Fort.'

-marcel
a***@spenarnc.xs4all.nl
2024-12-25 15:50:16 UTC
Permalink
Post by Anton Ertl
Post by dxf
Post by John
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,
*terminal*:2:1: warning: '3.14' is a double-cell integer; type `help' for more info ok 2
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
and then you can do things like
3.14 2.96 f* cr f.
*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.)
Post by Anton Ertl
- 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.
dxf
2024-12-26 03:06:48 UTC
Permalink
Post by John
...
Maybe I'm not doing it right, I'm just doing what's intuitive to me.
And yes, I'm running FORTH-F.  This is the DOS version.
Please help a wayward user....
Thanks for this. While there is a 'walk through' for Forth beginners
included in DXFORTH.TXT I omitted to mention how to enter doubles and
reals. This will be fixed in the next update (or I may just issue an
interim release as updates tend to be infrequent nowadays).
Loading...