Rounding on PowerPC with KIND=16

Andrew Pinski pinskia@gmail.com
Fri Feb 13 21:46:00 GMT 2015


On Fri, Feb 13, 2015 at 1:44 PM, Jerry DeLisle <jvdelisle@charter.net> wrote:
> On 02/13/2015 01:11 PM, Jerry DeLisle wrote:
>>
>> If you run this program on x86-64 vs Power PC, the Power PC appears to
>> have an
>> off by one spacing.  I assume this means the least significant bit is off
>> or we
>> are converting wrong when we write it.  I suspect this is a known issue,
>> but was
>> wondering if anyone has explored it?  Could it have something to do with
>> endianess?


PowerPC currently uses a pair double for long double and I bet you are
differences due to that.

Thanks,
Andrew

>>
>> Jerry
>>
>> program testit
>> use ISO_FORTRAN_ENV
>>    implicit none
>>    integer, parameter :: np = 16
>>    character(50) :: astring
>>    integer :: i, l, n
>>    real(kind=np) :: r, s, t, u
>>
>>    r = 1.0_np
>>    s = 10.0_np
>>    t = r/s
>>    u = (t + spacing(t)) * s
>>
>>    print "(g0)", r
>>    print "(g0)", s
>>    print "(g0)", t
>>    print "(g0)", u
>>    print "(g0)", t + spacing(t)
>>    print "(g0)", t - spacing(t)
>>    write(astring, "(g0)"), t
>>    print *, len(trim(astring)), "   ", trim(astring)
>>
>> end program
>>
>
> Sample Output
>
> x86-64:
>
> 1.00000000000000000000000000000000000
> 10.0000000000000000000000000000000000
> .100000000000000000000000000000000005
> 1.00000000000000000000000000000000019
> .100000000000000000000000000000000017
> .999999999999999999999999999999999928E-0001
>           37    .100000000000000000000000000000000005
>
> PowerPC
>
> 1.00000000000000000000000000000000000
> 10.0000000000000000000000000000000000
> .999999999999999999999999999999996919E-0001
> 1.00000000000000000000000000000000000
> .100000000000000000000000000000001233
> .999999999999999999999999999999981511E-0001
>           43    .999999999999999999999999999999996919E-0001
>



More information about the Fortran mailing list