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/fmtio/dtcscl.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fmtio/dtcscl.x')
-rw-r--r-- | sys/fmtio/dtcscl.x | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sys/fmtio/dtcscl.x b/sys/fmtio/dtcscl.x new file mode 100644 index 00000000..afd6adc5 --- /dev/null +++ b/sys/fmtio/dtcscl.x @@ -0,0 +1,35 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +# DTCSCL -- Scales a double precision real, maintaining maximum precision. +# Called by DTOC and CTOD. + +procedure dtcscl (v, e, sense) + +double v # value to be scaled +int e # exponent +int sense # sense of scaling (0=apply e to v; 1=calc e) + +begin + if (sense == 0) # scale v by 10 ** e + v = v * (10.0d0 ** e) + + else { # scale number to 0.1 <= v < 1.0 + if (v == 0.0d0) + e = 0 + else { + e = -1 + while (v < 0.1d0) { + v = v * 10.0d0 + e = e - 1 + if (v == 0.0d0) { # check for underflow to zero + e = 0 + break + } + } + while (v >= 1.0d0) { + v = v / 10.0d0 + e = e + 1 + } + } + } +end |