[Cfp-interest] Signaling NaNs and Fortran
Ian McIntosh
ianm at ca.ibm.com
Thu Mar 17 17:38:24 PDT 2011
IBM XLF version 13 running on AIX 5.3 prints:
snan, 32-bit prints as: NaNS
qnan, 32-bit prints as: NaNQ
snan, 64-bit prints as: NaNS
qnan, 64-bit prints as: NaNQ
I modified the program to include quad precision using the IBM PPC's
"double double":
program ieee_test_nan
use, intrinsic :: ieee_arithmetic
implicit none
real(4) :: ss, sq
real(8) :: ds, dq
real(16) :: qs, qq
ss = ieee_value(ss,ieee_signaling_nan)
sq = ieee_value(sq,ieee_quiet_nan)
ds = ieee_value(ds,ieee_signaling_nan)
dq = ieee_value(dq,ieee_quiet_nan)
qs = ieee_value(qs,ieee_signaling_nan)
qq = ieee_value(qq,ieee_quiet_nan)
write (*,*) "snan, 32-bit prints as: ", ss
write (*,*) "qnan, 32-bit prints as: ", sq
write (*,*) "snan, 64-bit prints as: ", ds
write (*,*) "qnan, 64-bit prints as: ", dq
write (*,*) "snan, 128-bit prints as: ", qs
write (*,*) "qnan, 128-bit prints as: ", qq
end
That printed:
snan, 32-bit prints as: NaNS
qnan, 32-bit prints as: NaNQ
snan, 64-bit prints as: NaNS
qnan, 64-bit prints as: NaNQ
snan, 128-bit prints as: NaNS
qnan, 128-bit prints as: NaNQ
- Ian McIntosh IBM Canada Lab Compiler Back End Support
and Development
From: "Fred J. Tydeman" <tydeman at tybor.com>
To: "cfp-interest at ucbtest.org" <cfp-interest at ucbtest.org>
Date: 03/16/2011 07:02 AM
Subject: [Cfp-interest] Signaling NaNs and Fortran
Sent by: cfp-interest-bounces at oakapple.net
Fortran, for some time, has had "support" for signaling NaNs.
The following program is supposed to create single and double
kinds of signaling and quiet NaNs; and then print them.
For those people who have access to Fortran compilers, would
you please run this and report back the results.
This is to help determine how C should print signaling NaNs.
program ieee_test_nan
use, intrinsic :: ieee_arithmetic
implicit none
real(4) :: ss, sq
real(8) :: ds, dq
ss = ieee_value(ss,ieee_signaling_nan)
sq = ieee_value(sq,ieee_quiet_nan)
ds = ieee_value(ds,ieee_signaling_nan)
dq = ieee_value(dq,ieee_quiet_nan)
write (*,*) "snan, 32-bit prints as: ", ss
write (*,*) "qnan, 32-bit prints as: ", sq
write (*,*) "snan, 64-bit prints as: ", ds
write (*,*) "qnan, 64-bit prints as: ", dq
end
---
Fred J. Tydeman Tydeman Consulting
tydeman at tybor.com Testing, numerics, programming
+1 (775) 358-9748 Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.
_______________________________________________
Cfp-interest mailing list
Cfp-interest at oakapple.net
http://mailman.oakapple.net/mailman/listinfo/cfp-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20110317/338e4525/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20110317/338e4525/attachment.gif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
Url : http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20110317/338e4525/attachment-0001.gif
More information about the Cfp-interest
mailing list