• Re: FP number syntax

    From albert@spenarnc.xs4all.nl@21:1/5 to minforth on Sat Dec 28 13:09:26 2024
    In article <ce49909934f23b4050a9d1a232af8ffe@www.novabbs.com>,
    minforth <minforth@gmx.net> wrote:
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Sat Jan 4 17:09:43 2025
    In article <2025Jan3.170018@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:
    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".

    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 ^

    - 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Paul Rubin on Tue Dec 31 21:51:35 2024
    Paul Rubin <no.email@nospam.invalid> writes:
    anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
    <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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@spenarnc.xs4all.nl on Tue Dec 31 21:57:55 2024
    albert@spenarnc.xs4all.nl writes:
    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.

    How would a proposal like this fare:
    "
    A double number is only recognized as it ends *and starts*
    with a period.

    Existing practice? What's wrong with "#314."?

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bernd Linsel@21:1/5 to dxf on Wed Jan 1 04:42:55 2025
    On 01.01.25 01:45, dxf wrote:


    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Wed Dec 25 13:41:13 2024
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to dxf on Wed Dec 25 15:28:08 2024
    dxf <dxforth@gmail.com> writes:
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Paul Rubin on Thu Dec 26 08:33:49 2024
    Paul Rubin <no.email@nospam.invalid> writes:
    dxf <dxforth@gmail.com> writes:
    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.").

    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.

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to dxf on Thu Dec 26 08:24:15 2024
    On Wed, 25 Dec 2024 23:07:42 +0000, dxf wrote:

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Wed Jan 1 11:47:16 2025
    dxf <dxforth@gmail.com> writes:
    On 1/01/2025 2:42 pm, Bernd Linsel wrote:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From HenryHH@21:1/5 to Anton Ertl on Wed Jan 1 12:48:01 2025
    On Wed, 1 Jan 2025 11:47:16 +0000, Anton Ertl wrote:

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Wed Jan 1 13:47:29 2025
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to mhx on Wed Jan 1 16:07:57 2025
    In article <099ee41be09b247d3b231cf91377b7a2@www.novabbs.com>,
    mhx <mhx@iae.nl> wrote:
    I have used DPL sporadically:
    <SNIPPED examples of assemblers>

    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.


    -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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to dxf on Thu Dec 26 10:48:24 2024
    dxf <dxforth@gmail.com> writes:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Thu Dec 26 19:08:25 2024
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Paul Rubin on Thu Dec 26 21:55:18 2024
    Paul Rubin <no.email@nospam.invalid> writes:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to Anton Ertl on Thu Dec 26 16:41:37 2024
    anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
    <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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to Paul Rubin on Fri Dec 27 01:26:54 2024
    On Fri, 27 Dec 2024 0:41:37 +0000, Paul Rubin wrote:

    anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
    <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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to dxforth@gmail.com on Thu Jan 2 15:07:34 2025
    In article <372725cbde75de8c5e4f86e726b42d159b3bba93@i2pn2.org>,
    dxf <dxforth@gmail.com> wrote:
    On 26/12/2024 10:28 am, Paul Rubin wrote:
    dxf <dxforth@gmail.com> writes:
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Thu Jan 2 15:21:46 2025
    In article <2024Dec31.225755@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:
    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.

    How would a proposal like this fare:
    "
    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.


    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.

    - 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@spenarnc.xs4all.nl on Thu Jan 2 15:51:11 2025
    albert@spenarnc.xs4all.nl writes:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Fri Jan 3 07:56:48 2025
    Old hat. The PDP-11 already had mixed multiplication and division.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Fri Dec 27 10:26:04 2024
    FWIW, probably nothing, there is no mention of DPL in the standard.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Fri Dec 27 12:04:26 2024
    In article <2024Dec26.225518@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    Paul Rubin <no.email@nospam.invalid> writes:
    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


    - 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to minforth on Fri Dec 27 12:17:14 2024
    In article <372a017823d7b347894fe0d32d621ade@www.novabbs.com>,
    minforth <minforth@gmx.net> wrote:
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Fri Dec 27 15:46:11 2024
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Fri Jan 3 09:59:20 2025
    dxf <dxforth@gmail.com> writes:
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Anton Ertl on Fri Jan 3 11:50:08 2025
    On Fri, 3 Jan 2025 9:59:20 +0000, Anton Ertl wrote:
    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...)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Fri Jan 3 15:37:14 2025
    In article <2025Jan2.165111@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:
    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.

    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.


    - 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@spenarnc.xs4all.nl on Fri Jan 3 16:00:18 2025
    albert@spenarnc.xs4all.nl writes:
    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".

    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.

    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.

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Sat Jan 4 10:03:27 2025
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)