character (len=:), allocatable :: msg
if (ieee_support_nan(r1)) then
if (ieee_class(r1) == ieee_quiet_nan) then
msg = "This s a quiet NaN."
else if (ieee_class(r1) == ieee_signaling_nan) then
msg = "This is a signaling NaN."
else
msg = "This is a number."
end if
else
msg = "NaNs are not supported."
end if
write (*,'(A)') msg
my @r = (nan, nan, 1.234);
setpayloadsig $r[1],'999';
foreach my $r1 ( @r ) {
if ( isnan $r1 ) {
printf "This is a %s NaN\n",
issignaling($r1) ? 'signaling' : 'quiet';
} else {
printf "This is not a NaN: %s\n", $r1;
}
}
# Output:
# This is a quiet NaN
# This is a signaling NaN
# This is not a NaN: 1.234