Software Archive
Read-only legacy content

I want my NaN

rahzan
Neuer Beitragender I
445Aufrufe
How can one assign NaN or some non-number.
var=NULL() does not seem to work.

The idea is to signal the caller that of a function that an invalid call was made and to recover gracefully.
Yes , I have not yet studied cvf's ability to throw proper exceptions.

tnx in adv.
Tim
0 Kudos
2 Antworten
njuffa
Einsteiger
445Aufrufe
One method I have used successfully in the past is to write the NAN bit pattern
into an integer variable and then use TRANSFER() to move this pattern into a
floating-point variable. E.g.

INTEGER*4 I
INTEGER*8 J
REAL*4 X
REAL*8 Y

I = Z'FFFFFFFF'
J = Z'FFFFFFFFFFFFFFFF'

X = TRANSFER(I)
Y = TRANSFER(J)

The bit pattern with all 1s is just one of the many available NaN bit patterns. By
using different NaNs, you could track where in a computation the uninitialized
data occured.

-- Norbert
rahzan
Neuer Beitragender I
445Aufrufe
Norb,
Thank much,
I also tot of dis:

negOne=-1.
x=sqrt(negOne)

Tim
Antworten