Default format for Float128
Jerry DeLisle
jvdelisle@frontier.com
Mon Sep 6 09:35:00 GMT 2010
On 09/01/2010 08:54 PM, Jerry DeLisle wrote:
Regarding isfinite used in write_float.def
> The following test taken from comment #19 of pr24685 fails with the new
> quad float patch on x86-64. The values come out +Infinity on my system
> here.
>
> program huge_real10_formatted
> integer, parameter :: k = 16
> real(kind=k) :: a,b(2), c
> character(len=180) :: tmp
> ! Test real(k) scalar and array formatted IO with big value
> b(:) = huge (1.0_k)/2
> print *, 'real(16) big value: ', b(1)
> write (tmp, *) b
> read (tmp, *) a, c
> print *, 'same value read again: ', a
> print *, 'difference: looks broken ', a-b(1)
> ! Test with really big value
> b(:) = huge (1.0_k)
> print *, 'huge value: ', b(1)
> write (tmp, *) b
> read (tmp, *) a, c
> print *, "tmp=", tmp
> print *, "Whats this about!!"
> print *, a
> print *, b(1)
> print *, b(2)
> print *, c
> !if (a /= b(1)) call abort ()
> !if (c /= b(2)) call abort ()
> end program huge_real10_formatted
>
> $ ./a.out
> real(16) big value: 5.94865747678615882542880000000000000E+4931
> same value read again: 5.94865747678615882542880000000000000E+4931
> difference: looks broken 3.36685996541765098451450000000000000E+4907
> huge value: +Infinity
> tmp= +Infinity +Infinity
> Whats this about!!
> +Infinity
> +Infinity
> +Infinity
> +Infinity
>
> I will keep picking at this, but I think we need to leave the default
> widths alone. Then for platforms using libquad, consider reduced width.
> Also see why Huge is coming out Infinity. ???
>
Replacing isfinite with finiteq in write_float.def
#define WRITE_FLOAT(x,y)\
{\
GFC_REAL_ ## x tmp;\
tmp = * (GFC_REAL_ ## x *)source;\
sign_bit = __builtin_signbit (tmp);\
- if (!isfinite (tmp))\
+ if (!finiteq (tmp))\
{ \
write_infnan (dtp, f, isnan (tmp), sign_bit);\
return;\
Correctly determines the finite-ness of the KIND=16 real in the test and the
correct results are given. So we need to somehow define isfinite for
real(KIND=16) values and invoke it here.
This is the last of my comments for now.
Summarizing:
For KIND=16 floats on systems using libquad
1. define MIN_FIELD_WIDTH 46
2. define isfinite function
Regards,
Jerry
More information about the Fortran
mailing list