[fortran,patch] Patch for PR 14394 - Precision of real type.
Tianjiao Zhang
tjzhang@quantumstates.com
Wed Mar 10 08:31:00 GMT 2004
Hi,
Excuse me that for pgf90 compiler,
pgf90 -r8 z.f gives the same result -255.9987041345172 for both real and
real*8.
Without the switch -r8,
real*8 gives -255.9958332631721
I used g77 and it gave -255.995833
I used gcc
#include <math.h>
int main(int argc,char **argv) {
long double a,b;
b= 1.5747025767L;
a=tan(b);
printf("%20.16Lf\n",a);
}
and it gave:
-255.9987041345172359
So we can use gcc to check the accuracy actually ?
Sincerely,
Tianjiao
-----------
Tianjiao Zhang wrote:
>SunOS 5.9 Generic_112233-08 sun4u sparc SUNW,Sun-Fire-880
>f77 WorkShop Compilers 4.2
>
>-255.99870413452
>
>On Linux 2.4.18-3smp #1i686 unknown
>pgf90 4.0-2
>-255.9958332631721
>
>
>Feng Wang wrote:
>
>
>
>>Hi, all
>> This patch fix PR 14394. Reported by Bud. Test case:
>>cat z.f
>> REAL AVS,BVS
>> BVS = 1.5747025767
>> AVS = TAN(BVS)
>> PRINT*,AVS
>> END
>> There is one problem converting the real type from mpf to gcc tree. With
>>-fdump-parse-tree we can see fortran gets the input and parse correctly.
>>gfc_conv_mpf_to_tree in trans-const.c use string as the intermediate of the
>>conversion. As convert mpf to string, we specify the maximum digits number of
>>the real value. In my patch, I loosen the limit.
>> I tested real and real*8 type with the patch. The real type got the same
>>result with Intel's compiler. But with real*8 type, gfortran gave the result:
>>-255.998704134517, compared with Intel's -255.995833263172. The difference of
>>them is above 0.002. With calculator I comfirmed the gfortran's result should
>>be correct. But can anyone give more comparation with other compilers. What's
>>your opinion?
>>
>>
>>Feng Wang
>>
>>_________________________________________________________
>>Do You Yahoo!?
>>ÃêëÃâ·ÃµÃÃÃ
»¢µçÃã¬ÃÃÃÃâ²á»ñÃù¶îÃâ60ÃÃÃøÃç´æ´¢¿Ã¼ä
>>http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.mail.yahoo.com
>>
>>
>>
>>
>>
>>
>
>
>
>
>
>
More information about the Fortran
mailing list