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


Groups > comp.lang.forth > #135279

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-07-27 12:20 -0500
Organization A noiseless patient Spider
Message-ID <114840k$3ckvu$1@dont-email.me> (permalink)
References <113lcfk$18opt$1@dont-email.me> <nnd$781d5b9d$3afe6505@cbd31617988c463d> <1144u7g$2bpng$2@dont-email.me> <nnd$73279277$6bcca128@35b6dbc9a1b28f0f>

Show all headers | View raw


On 7/26/26 13:13, albert@SPENARNC.XS4ALL.NL wrote:
> Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
...
>> That's encouraging. Try these two tests from the rounding section
>>
>> dec_t{  1.000000000000000111022302462515654042363166809082031250e+00 !r
>> -> }t
>> hex_t{  r8 2L@ -> 3ff00000 00000000 }t
>>
>> dec_t{  1.000000000000000111022302462515654042363166809082031251e+00 !r
>> -> }t
>> hex_t{  r8 2L@ -> 3ff00000 00000001 }t
>>
>> Notice that the two decimal inputs are different by 1 in the last
>> decimal place. But the round to nearest changes the converted bit
>> pattern by 1 bit.
> 
> Okay, now I got:
> S[ 3FF0000000000000 3FF0000000000001 ]   3FF0000000000001 ?
> ciforth ERROR # 41 : REGRESSION TEST FAILS, RETURN VALUE ERROR
> 
>>
>>> My first impression is that trimming the number to IEEE generates the correct
>>> result.
>>
> This impression is wrong.
> Apparently I do not understand the fine points of this matter.

The explanation of why the second test value has the lsb of the 52 bit 
fractional part of the converted number set is the following. We can 
ignore the implied 1 for the msb. That bit just adds the 1.0e0 to the 
number.

Input 1)

1.000000000000000111022302462515654042363166809082031250e+00

the converted IEEE double precision number

3ff0000000000000

has the fractional part, all 52 of the least significant bits, set to 
zero. The exponent is also zero. This means that the nearest number 
rounding for the number is

1.000 ... ... ...


Input 2)

1.000000000000000111022302462515654042363166809082031251e+00

the converted IEEE double precision number is

3ff0000000000001

The lsb of the 52 bit fraction is now 1. The fractional part is now

2^-52

which, added to the implied msb of 1, is the next representable IEEE 
double precision floating point number:

55 set-precision
2.0e0 -52e0 F** 1.0e0 F+ FS.
1.000000000000000222044604925031308084726333618164062500e+00  ok

The input for the second case is nearer to the representable number 
above, rather than it is to the representable number below this one, 
which is 1.000 ... ... ...

In contrast, input 1) is closer to 1 than to the number above.

--
Krishna




Back to comp.lang.forth | Previous | Next — Previous in thread | Next 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