The makes the smallest gap in x = 1/16 - nextafter(1/16, 0) = 1/2^57 for reals = 0.7 pm on the earth if x is an angle in degrees. (This is about 1000 times more resolution than we get with angles around 90 degrees.) We use this to avoid having to deal with near singular cases when x is non-zero but tiny (e.g., 1.0e-200).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(in) | :: | x |
real(wp) function AngRound(x) real(wp),intent(in) :: x real(wp) :: y, z z = 1.0_wp/16.0_wp y = abs(x) ! The compiler mustn't "simplify" z - (z - y) to y if (y < z) y = z - (z - y) AngRound = sign(y, x) end function AngRound