Created
October 11, 2011 10:30
-
-
Save cvr/1277782 to your computer and use it in GitHub Desktop.
Avoid possible division by zero by limiting the divisor (FORTRAN)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REAL, PARAMETER :: SMALL = 1.E-18 | |
!! for a divisor b>0 | |
c = a/MAX(b, SMALL) | |
!! for a divisor b with an arbitrary sign | |
c = a/SIGN(MAX(ABS(b), SMALL), b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment