Dan
2008-09-24 22:27:04 UTC
I sometime write code as I've shown below. Here, xout, is calculated
within a subroutine or it is assigned using a function result. There
are times when xout cannot be calculated for whatever reason. Thus,
in the subroutine or function, I'll often set xout=HUGE(xout).
Then... later, as shown below, I test to see if xout=HUGE(xout).
Generally, I don't test for equality with real numbers for the normal
reasons. However, I've been doing the test as described here under
the assumption that it is a safe test since HUGE() has a well defined
value.
My question is: Am I safe doing this or might there be pitfalls that
will get me slapped in the face when I'm not looking?
Alternatively, any of you have any ways of handling these error
conditions that you feel are particularly nice and also safe?
REAL :: xin, xout
:::::: assign value to xin ::::::
CALL Evaluate( xin, xout )
or
xout = Evaluate( xin)
IF( xout == HUGE(xout) )THEN
::::: error processing code or whatever
END IF
Thanks, Dan
within a subroutine or it is assigned using a function result. There
are times when xout cannot be calculated for whatever reason. Thus,
in the subroutine or function, I'll often set xout=HUGE(xout).
Then... later, as shown below, I test to see if xout=HUGE(xout).
Generally, I don't test for equality with real numbers for the normal
reasons. However, I've been doing the test as described here under
the assumption that it is a safe test since HUGE() has a well defined
value.
My question is: Am I safe doing this or might there be pitfalls that
will get me slapped in the face when I'm not looking?
Alternatively, any of you have any ways of handling these error
conditions that you feel are particularly nice and also safe?
REAL :: xin, xout
:::::: assign value to xin ::::::
CALL Evaluate( xin, xout )
or
xout = Evaluate( xin)
IF( xout == HUGE(xout) )THEN
::::: error processing code or whatever
END IF
Thanks, Dan