Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #135413

Re: kForth-Win32 fix for decimal string to double float conversion

From Krishna Myneni <krishna.myneni@ccreweb.org>
Newsgroups comp.lang.forth
Subject Re: kForth-Win32 fix for decimal string to double float conversion
Date 2026-08-24 18:55 -0500
Organization A noiseless patient Spider
Message-ID <116illh$3a5tj$1@dont-email.me> (permalink)
References <113lcfk$18opt$1@dont-email.me>

Show all headers | View raw


On 7/20/26 9:48 AM, Krishna Myneni wrote:
> I recently fixed a problem with kForth-Win32's conversion of decimal 
> strings to IEEE double precision floats e.g., with rounding mode set to 
> round nearest (with ties to eve), the string
> 
> "1.000 000 000 000 000 111 022 302 462 515 654 042 363 166 809 082 031 
> 251 e0" (spaces added for clarity)
> 
> converted to the IEEE 64-bit binary pattern (shown in hex, high-dword 
> low- dword)
> 
> 3ff00000 00000000
> 
> representing the exact number 1.000 ...
> 
> instead of converting to the nearest representable IEEE 754 double 
> precision number,
> 
> 3ff00000 00000001
> 
> which has the value
> 
> 1.000 000 000 000 000 222 044 604 925 031 308 084 726 333 618 164 062 500
> 
...
> There are several approaches to doing the conversion correctly (see the 
> paper mentioned above, and the references therein). The replacement 
> strtod() function in dtoa.c uses its built-in big integer arithmetic to 
> do the conversions, and this library is apparently used in languages 
> like python and Java.
> 
> kForth-Win32, as of version 2.5.5, uses the strtod() function from 
> dtoa.c. ...
Previously, I used the high quality strtod() function in dtoa.c to do 
decimal string to binary floating point conversions.

Now, kForth-Win32 uses the high-quality dtoa() function in dtoa.c to do 
double-precision binary to decimal string conversions.

https://netlib.org/fp/dtoa.c

The dtoa() function in this code is ideally suited for implementing 
Forth's REPRESENT so I managed to solve two problems: implement a high 
quality REPRESENT and redefine FS. using REPRESENT. The new FS. output 
in kForth-Win32 is the same as in the linux versions (kForth-32 and 
kForth-64). Floating point i/o is now consistent between the different 
kForth variants.

The kForth-Win32 commit has not yet been pushed out, but will be soon. 
Now I can add REPRESENT tests to my system test code, fpio-test.4th.

--
Krishna Myneni

Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-20 09:48 -0500
  Re: kForth-Win32 fix for decimal string to double float conversion albert@SPENARNC.XS4ALL.NL - 2026-07-21 11:40 +0200
    Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-21 06:20 -0500
      Re: kForth-Win32 fix for decimal string to double float conversion albert@SPENARNC.XS4ALL.NL - 2026-07-25 16:08 +0200
        Re: kForth-Win32 fix for decimal string to double float conversion peter <peter.noreply@tin.it> - 2026-07-25 17:07 +0200
          Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-25 13:22 -0500
            Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-25 13:30 -0500
        Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-25 13:17 -0500
          Re: kForth-Win32 fix for decimal string to double float conversion dxf <dxforth@gmail.com> - 2026-07-26 13:15 +1000
            Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-26 07:18 -0500
              Re: kForth-Win32 fix for decimal string to double float conversion dxf <dxforth@gmail.com> - 2026-07-31 14:54 +1000
                Re: kForth-Win32 fix for decimal string to double float conversion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-07-31 08:35 +0000
                Re: kForth-Win32 fix for decimal string to double float conversion albert@spenarnc.xs4all.nl - 2026-07-31 12:05 +0200
                Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-31 07:54 -0500
                Re: kForth-Win32 fix for decimal string to double float conversion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-07-31 16:55 +0000
                Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-31 14:40 -0500
                Re: kForth-Win32 fix for decimal string to double float conversion anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-08-01 08:23 +0000
                Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-08-01 06:42 -0500
    Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-21 11:30 -0500
      Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-21 14:47 -0500
  Re: kForth-Win32 fix for decimal string to double float conversion albert@SPENARNC.XS4ALL.NL - 2026-07-25 23:42 +0200
    Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-25 18:47 -0500
      Re: kForth-Win32 fix for decimal string to double float conversion albert@SPENARNC.XS4ALL.NL - 2026-07-26 13:11 +0200
  Re: kForth-Win32 fix for decimal string to double float conversion albert@SPENARNC.XS4ALL.NL - 2026-07-26 13:22 +0200
    Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-26 07:23 -0500
      Re: kForth-Win32 fix for decimal string to double float conversion albert@SPENARNC.XS4ALL.NL - 2026-07-26 20:13 +0200
        Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-07-27 12:20 -0500
  Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-08-11 07:24 -0500
  Re: kForth-Win32 fix for decimal string to double float conversion Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-08-24 18:55 -0500

csiph-web