diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/gio/fpnormr.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/gio/fpnormr.x')
-rw-r--r-- | sys/gio/fpnormr.x | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sys/gio/fpnormr.x b/sys/gio/fpnormr.x new file mode 100644 index 00000000..45ad3f2a --- /dev/null +++ b/sys/gio/fpnormr.x @@ -0,0 +1,40 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <mach.h> + +# FP_NORMR -- Normalize a single precision number x to the value NORMX, in the +# range [1-10). EXPON is returned such that x = normx * (10.0E0 ** expon). + +procedure fp_normr (x, normx, expon) + +real x # number to be normalized +real normx # X normalized to the range 1-10 (output) +int expon # exponent of normalized X +real absx, tol + +begin + tol = EPSILONR * 10.0 + absx = abs (x) + expon = 0 + + if (absx > 0) { + while (absx < (1.0E0 - tol)) { + absx = absx * 10.0E0 + expon = expon - 1 + if (absx == 0.0) { # check for underflow to zero + normx = 0 + expon = 0 + return + } + } + while (absx >= (10.0E0 + tol)) { + absx = absx / 10.0E0 + expon = expon + 1 + } + } + + if (x < 0) + normx = -absx + else + normx = absx +end |