Rounding on PowerPC with KIND=16
Jerry DeLisle
jvdelisle@charter.net
Fri Feb 13 21:11:00 GMT 2015
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?
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
More information about the Fortran
mailing list