Default format for Float128
Steve Kargl
sgk@troutmask.apl.washington.edu
Thu Sep 2 18:02:00 GMT 2010
On Wed, Sep 01, 2010 at 08:54:32PM -0700, Jerry DeLisle wrote:
> Hi all,
>
> With FX help I managed to get a build working with the libquad support.
> (allowing me to test)
>
> The following program illustrates some default formatting.
>
> program test_quad
> real(16) :: num1, num2, num3
> real(8) :: tmp
>
> num1 = 23.456_16 / 3.3_16
> num2 = 42.86_16
> num3 = -5.2562-16
> tmp = num1 + num2 + num3
> print *, "1234567890123456789012345678901234567890"
> write(*,*) tmp
> write(*,*) num1
> write(*,*) num2
> write(*,*) num3
> write(*,*) num1 + num2 + num3
> print *, "1234567890123456789012345678901234567890"
> print *, 1.0_16/3.0_16
> print *, 1.0_10/3.0_10
> print *, 1.0_8/3.0_8
> print *, 1.0_4/3.0_4
> end program test_quad
>
> Which on my system, results in:
>
> $ ./a.out
> 1234567890123456789012345678901234567890
> 28.711679904822148
> 7.1078787878787878787879000000000000
> 42.860000000000000000000000000000000
> -21.256198883056640625000000000000000
> 28.711679904822147253788000000000000
> 1234567890123456789012345678901234567890
> 0.33333333333333333333333000000000000
> 0.33333333333333333334
> 0.33333333333333331
> 0.33333334
>
> There appears to be a lot of excess width here. If I modify write.c with
> this:
>
> Index: write.c
> ===================================================================
> --- write.c (revision 163712)
> +++ write.c (working copy)
> @@ -1447,8 +1447,8 @@
> f->u.real.e = 4;
> break;
> case 16:
> - f->u.real.w = 44;
> - f->u.real.d = 35;
> + f->u.real.w = 32;
> + f->u.real.d = 23;
Are you sure this is correct?
troutmask:sgk[205] cat j.f90
real(16) x
print *, precision(x), digits(x)
end
troutmask:sgk[206] gfc4x -o z j.f90
troutmask:sgk[207] ./z
33 113
There are 33 decimal digits of precision.
Shouldn't the default format be something
like s0.[33 digits]ES00 where s and S are
+ or -. This gives w = 40 and d = 33.
Of course, I could be wrong about what real.[wd]
mean.
--
Steve
More information about the Fortran
mailing list