Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing quadruple-precision numbers

65 views
Skip to first unread message

Arjen Markus

unread,
Jul 2, 2015, 3:36:20 AM7/2/15
to
I have been experimenting a bit with quadruple-precision numbers, as they are supported by both Intel Fortran and gfortran. But I run into a problem printing larger values of this kind of numbers. Consider this program:

program chkquad
implicit none

real(kind=16) :: x, y

x = 1.0_16
y = huge(y)

write(*,*) x, y
write(*,'(2e16.5)') x, y
end program chkquad

The output it produces is:

1.00000000000000000000000000000000
1.189731495357231765085759326628007E+4932
0.10000E+01****************

I would have said that 16 positions are enough to accommodate for the wide exponent, but even 20 positions produce the sequence of asterisks.

This is the result with both Intel Fortran and gfortran (on Windows, fairly recent versions).

What edit descriptors should I put in the format to print these numbers?

Regards,

Arjen

FX

unread,
Jul 2, 2015, 4:10:08 AM7/2/15
to
> I would have said that 16 positions are enough to accommodate for the
> wide exponent, but even 20 positions produce the sequence of asterisks.
>
> This is the result with both Intel Fortran and gfortran (on Windows,
> fairly recent versions).
>
> What edit descriptors should I put in the format to print these
> numbers?

It's the exponent that doesn't fit in 3-digits. You need to use the
Ew.dEe edit descriptor:

write(*,*) huge(0._16)
write(*,'(E40.30E4)') huge(0._16)
end

See section 10.7.2.3.3 in Fortran 2008 for details.

--
FX

Arjen Markus

unread,
Jul 2, 2015, 5:07:48 AM7/2/15
to
Op donderdag 2 juli 2015 10:10:08 UTC+2 schreef FX:
Ah, thanks! I had forgotten about that bit.

Regards,

Arjen
0 new messages