Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #135709
| From | Krishna Myneni <krishna.myneni@ccreweb.org> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: ddfloat library: the behavior of >dd |
| Date | 2026-09-15 07:33 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <118bdvk$2e9ov$1@dont-email.me> (permalink) |
| References | (11 earlier) <6aa7c5cf$1@news.ausics.net> <1188htd$2vabu$1@dont-email.me> <2026Sep14.170043@mips.complang.tuwien.ac.at> <1189ler$1sfui$1@dont-email.me> <2026Sep14.225816@mips.complang.tuwien.ac.at> |
On 9/14/26 3:58 PM, Anton Ertl wrote: > Krishna Myneni <krishna.myneni@ccreweb.org> writes: >> On 9/14/26 10:00 AM, Anton Ertl wrote: >> ... >>> >>> I am debating with myself whether one should use the closest FP number >>> with round-to-nearest, or the closest with round-to-absolute-higher. >>> Maybe depends on the purpose of this normalization. >>> >> Is your idea to stay within 1 ulp error for the conversion, but use a >> simpler algorithm? > > No. > > The idea here is as follows: > > You have your number X that you want to normalize to a power of 10. > For that number there exist numbers Y, Y', Z, and Z', where > > Y > X >= Z > Y >= 10^(n+1) > prev(Y) > Z >= 10^n > prev(Z) > > Where prev(V) produces the largest (in absolute terms) FP value <V. > So Y or Z are either powers of 10 or the smallest FP numbers just > above a power of 10, and they are those numbers which are the > normalization boundaries of X. > > For normalizing X, we would love to divide by 10^n, but if that's not > representable as FP number, and if we want to use our FP words to do > that, what do we use? > > 1) The result that has the best chance of being close to the proper > result would be to use the FP number Z' that's closest to 10^n (round > to nearest). But if Z'=prev(Z) (which will probably be the case half > of the time when 10^n cannot be represented exactly), the result of > X/Z' will be larger than it should be, and, in particular, even if > X=Z, X/Z' might have a value >1.0, which is probably not desired. > > 2) Instead, you could normalize as X/Z, i.e., the number that's > closest to 10^n if you round away from 0 (what I described as > round-to-absolute-higher above). But Z can be up to 1ulp away from > 10^n, so the result of X/Z will, on averge be further from the > intended value than X/Z'. > > Another option is to normalize in a more precise way than performing a > double-double FP multiplication or division, but that's more costly. > The present implementation of >DD decimal string to double-double conversion in kForth (dd_io.4th) is off by 14 ulp for the case of pi, which is not good enough, so it will be useful to compare your proposed conversion procedure. \ For 64-bit Forth with a separate fp stack 3.1415926535897931e0 1.2246467991473532e-16 ddconstant ddpi 32 set-precision ddpi ddfs. +3.1415926535897932384626433832795 dd 0 ok ddvariable ref ddvariable cnv ddpi ref dd! \ reference \ convert decimal string to double double with >DD S" 3.1415926535897932384626433832795dd0" >dd cnv dd! cnv dd@ ddfs. +3.1415926535897932384626433832791 dd 0 ok 17 set-precision \ print high and low double precision fp numbers ref dd@ fswap fs. 2 spaces fs. 3.1415926535897931e+00 1.2246467991473532e-16 ok cnv dd@ fswap fs. 2 spaces fs. 3.1415926535897931e+00 1.2246467991473498e-16 ok \ Note the loss of significant digits in the low double for cnv \ What is the ulp error for cnv? hex ref 8 + @ u. \ print the 64-bit hex value of ref, low double 3CA1A62633145C07 ok cnv 8 + @ u. \ print the 64-bit hex value of cnv, low double 3CA1A62633145BF9 ok \ difference in ulp decimal cnv 8 + @ ref 8 + @ - . -14 ok -- Krishna
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-10 19:33 +0200
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-10 13:35 -0500
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-10 22:10 +0200
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-10 16:51 -0500
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-11 12:16 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-11 12:05 +0200
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-12 00:27 +0200
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-11 20:29 -0500
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-12 12:02 +1000
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-12 10:24 -0500
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-12 10:45 +0200
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-12 19:51 +1000
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-12 22:47 +1000
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-13 03:14 +1000
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-12 13:02 -0500
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-13 15:44 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-13 09:00 +0200
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-13 20:33 +1000
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-14 13:28 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-14 10:09 +0200
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-14 20:00 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-14 12:22 +0200
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-14 21:59 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-14 14:26 +0200
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-15 01:32 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-14 21:08 +0200
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-14 15:25 -0500
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-15 13:11 +1000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-15 14:06 +0200
Re: ddfloat library: the behavior of >dd dxf <dxforth@gmail.com> - 2026-09-16 00:05 +1000
Re: ddfloat library: the behavior of >dd anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-09-14 15:00 +0000
Re: ddfloat library: the behavior of >dd marcel hendrix <mhx@iae.nl> - 2026-09-14 21:15 +0200
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-14 15:29 -0500
Re: ddfloat library: the behavior of >dd anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-09-14 20:58 +0000
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-15 07:33 -0500
Re: ddfloat library: the behavior of >dd anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-09-15 15:53 +0000
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-15 15:23 -0500
Re: ddfloat library: the behavior of >dd Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-09-15 17:53 -0500
csiph-web