Article View: comp.lang.forth
Article #147Tests for (DDFS.)
From: Krishna Myneni
Date: Tue, 20 Oct 2026 13:47
Date: Tue, 20 Oct 2026 13:47
83 lines
4048 bytes
4048 bytes
The double-double (dd) precision floating format consists of a pair of
IEEE 754 binary64 (double precision) floats. It effectively provides a
significand which has twice the precision of an ordinary binary64 float:
p = 2*53 = 106 bits
An ordinary binary64 number can be converted to a decimal string using
REPRESENT. With a high-quality REPRESENT which provides >= 33
significant decimal digits we can generate test cases for binary to
decimal conversion of dd precision numbers simply by using binary64
numbers.
Furthermore, if REPRESENT can provide a larger number of digits, it is
possible to generate test cases for much larger p e.g. binary128 or
binary256 numbers, simply using double-precision floats.
The following test program illustrates the use of double precision
numbers to check the binary to decimal conversion of dd precision
numbers with the word (DDFS.). In kForth-x, this word is provided in the
latest update of dd_io.4th (link below) -- the test program is based on
this assumption.
I will emphasize again the important part: The reference string is the
one obtained with (FS.) from a double-precision number with a PRECISION
set to 32.
The output shows that (DDFS.) as presently implemented in dd_io.4th
fails for one of the test cases (test 2), and probably for many more cases.
--
Krishna Myneni
Link to latest dd_io.4th, providing (DDFS.), for use with ddarith.4th:
https://github.com/mynenik/kForth-32/blob/master/forth-src/dd_io.4th
=== begin ddfsdot-test.4th ===
\ ddfsdot-test.4th
\
\ Test (ddfs.) double double precision binary to
\ decimal string conversion.
\
\ Use double precision fp to generate reference
\ outputs for ddfs. This requires a high quality
\ REPRESENT capable of providing properly rounded
\ binary to decimal conversion with 33 digits.
\
\ p = significand bits
\ PRECISION (P_min) = 1 + ceiling(p*log10(2))
\
\ p = 53, PRECISION = 17
\ p = 106, PRECISION = 33
\
\ K. Myneni, <krishna.myneni@ccreweb.org>
include ans-words
include ttester
include ddarith
include dd_io
32 set-precision
[UNDEFINED] (ddfs.) ABORT" Needs definition of (DDFS.)" [THEN]
\ Compare the decimal significands of two scientific notation
\ strings e.g. one generated by (fs.) and one by (ddfs.) to
\ PRECISION digits.
: compsig ( caddr1 u1 caddr2 u2 -- n )
\ replace both string lengths u1 and u2 with PRECISION+1
PRECISION 1+ swap drop swap >r swap drop r> over compare
;
fvariable r
TESTING (DDFS.)
t{ ( 1) 0.30000000000000003e0 r df! r df@ (fs.) r df@ 0e (ddfs.)
compsig -> 0 }t
t{ ( 2) 9.9999993504564039e-39 r df! r df@ (fs.) r df@ 0e (ddfs.)
compsig -> 0 }t
t{ ( 3) -1.0000000133514319e-10 r df! r df@ (fs.) r df@ 0e (ddfs.)
compsig -> 0 }t
t{ ( 4) -9007199254740991.5e0 r df! r df@ (fs.) r df@ 0e (ddfs.)
compsig -> 0 }t
=== end ddfsdot-test.4th ===
Technical Details
Message-ID:
<11b7rcu$31u3u$1@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Krishna Myneni <krishna.myneni@ccreweb.org> Newsgroups: comp.lang.forth Subject: Tests for (DDFS.) Date: Tue, 20 Oct 2026 08:47:10 -0500 Organization: A noiseless patient Spider Lines: 83 Message-ID: <11b7rcu$31u3u$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 20 Oct 2026 13:47:11 +0000 (UTC) Injection-Info: dont-email.me; logging-data="3209342"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19tCJb5XP+sxkDvvZwQRyai"; posting-host="a4217b4f3342bc26cffa14f31fc9d3e3" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:klIQ6JVoxCA5FlPcXGLdyhYFZsc= sha256:rWHxfjervwhl0MJCh58ZPAgxkU8R4s3q0g7ehtCWxgQ= sha1:3j/2ESoQ9vA/XEM6x6/Bl75dZ0I= sha256:KqvufCYIfzcRERKwaaopiBdqyX4h4NgUxh16v0nAiuo= Content-Language: en-US