On 10/20/26 7:15 PM, dxf wrote:
> On 21/10/2026 4:26 am, marcel hendrix wrote:
>> On 10/20/2026 6:15 PM, Krishna Myneni wrote:
>>> On 10/20/26 8:47 AM, Krishna Myneni wrote:
>>> ...
>>>>
>>>> ...
>>>> 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.
>>>> ...
>>>
>>> Typing the string outputs from (FS.) and (DDFS.) shows that (DDFS.) is not rounding properly.
>> Simply setting the low part of a double double to 0 might be a bit too simplistic? Is the difference in the range of 1e-15 .. 1e-17 ?
>
> I wasn't aware any JVN packages performed rounding. AFAIK some implementations
> (yours?) limited numbers printed to PRECISION but that this was truncation - not
> rounding. Rounding presented a whole new problem - why I never attempted it.
>
The present iteration of (DDFS.) in kForth's dd_io.4th includes some changes you introduced. I would have to back and check JVN's original code (which uses a state machine) to see it performs differently than the subroutine ddwrite() in Bailey's ddfun Fortran 90 package, which is what is used in my program dp2_to_dd.f90 (listed below).
It is more productive to make (DDFS.) a Forth equivalent to ddwrite(), to provide the same performance.
What does your present version of (DDFS.) output on these tests?
--
KM
=== begin code for dp2_to_dd ===
! dp2_to_dd.f90
!
! K. Myneni, 16 Sep 2026
!
! Input a double double precision (DD) number as a
! pair of double precision (DP) numbers and display
! the DD number in scientific notation. The program
! also displays the input DP numbers in scientific
! notation and their hex values.
!
! Build:
! $ gfortran -O3 -o dp2_to_dd dp2_to_dd.f90 ddmodule.o ddfuna.o ddfune.o second.o
!
! Build assumes you have built the Fortran ddfun-v04 package using the
! shell script gnu-complib-dd.scr
! The script will generate the .o files for linking to the program below.
!
! Revisions:
! 2026-09-18 km; directly set the two DP numbers of a DD variable
!
program dp2todd
use ddmodule
implicit none
real (ddknd) a(2)
type (dd_real) t1, t2
print *, 'Enter a pair of double precision (DP) numbers:'
read(*, '(D28.16,D28.16)') a(1), a(2)
print *, 'The two DP numbers are:'
write(*,'(E30.17,2X,E30.17)') a(1), a(2)
print *, 'The two DP hex values are:'
write(*, '(Z16,2X,Z16)') a(1), a(2)
print *, 'The double double (DD) value of the pair is:'
t1%ddr(1) = a(1)
t1%ddr(2) = a(2)
call ddwrite(6,40,32,t1)
end program dp2todd
=== end code ===