diff options
| author | Paul Eggert | 1996-12-30 08:07:51 +0000 |
|---|---|---|
| committer | Paul Eggert | 1996-12-30 08:07:51 +0000 |
| commit | ad8d56b96027294edeb48a7d529e109a9dcc3034 (patch) | |
| tree | a91783beed07fc1fa0352dc42865df28e773bd86 /src | |
| parent | d137ae2faa5be6a2af07e60c103f39264ce3829b (diff) | |
| download | emacs-ad8d56b96027294edeb48a7d529e109a9dcc3034.tar.gz emacs-ad8d56b96027294edeb48a7d529e109a9dcc3034.zip | |
<float.h>: Include if STDC_HEADERS.
(IEEE_FLOATING_POINT): New symbol.
(float_arith_driver, Fmod):
Test for division by 0 only if ! IEEE_FLOATING_POINT.
Diffstat (limited to 'src')
| -rw-r--r-- | src/data.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/data.c b/src/data.c index e64dcf800b3..bd7d0bc4ac5 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -35,9 +35,20 @@ Boston, MA 02111-1307, USA. */ | |||
| 35 | #ifdef LISP_FLOAT_TYPE | 35 | #ifdef LISP_FLOAT_TYPE |
| 36 | 36 | ||
| 37 | #ifdef STDC_HEADERS | 37 | #ifdef STDC_HEADERS |
| 38 | #include <float.h> | ||
| 38 | #include <stdlib.h> | 39 | #include <stdlib.h> |
| 39 | #endif | 40 | #endif |
| 40 | 41 | ||
| 42 | /* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */ | ||
| 43 | #ifndef IEEE_FLOATING_POINT | ||
| 44 | #if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ | ||
| 45 | && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) | ||
| 46 | #define IEEE_FLOATING_POINT 1 | ||
| 47 | #else | ||
| 48 | #define IEEE_FLOATING_POINT 0 | ||
| 49 | #endif | ||
| 50 | #endif | ||
| 51 | |||
| 41 | /* Work around a problem that happens because math.h on hpux 7 | 52 | /* Work around a problem that happens because math.h on hpux 7 |
| 42 | defines two static variables--which, in Emacs, are not really static, | 53 | defines two static variables--which, in Emacs, are not really static, |
| 43 | because `static' is defined as nothing. The problem is that they are | 54 | because `static' is defined as nothing. The problem is that they are |
| @@ -1912,6 +1923,7 @@ enum arithop | |||
| 1912 | { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin }; | 1923 | { Aadd, Asub, Amult, Adiv, Alogand, Alogior, Alogxor, Amax, Amin }; |
| 1913 | 1924 | ||
| 1914 | extern Lisp_Object float_arith_driver (); | 1925 | extern Lisp_Object float_arith_driver (); |
| 1926 | extern Lisp_Object fmod_float (); | ||
| 1915 | 1927 | ||
| 1916 | Lisp_Object | 1928 | Lisp_Object |
| 1917 | arith_driver (code, nargs, args) | 1929 | arith_driver (code, nargs, args) |
| @@ -2029,7 +2041,7 @@ float_arith_driver (accum, argnum, code, nargs, args) | |||
| 2029 | accum = next; | 2041 | accum = next; |
| 2030 | else | 2042 | else |
| 2031 | { | 2043 | { |
| 2032 | if (next == 0) | 2044 | if (! IEEE_FLOATING_POINT && next == 0) |
| 2033 | Fsignal (Qarith_error, Qnil); | 2045 | Fsignal (Qarith_error, Qnil); |
| 2034 | accum /= next; | 2046 | accum /= next; |
| 2035 | } | 2047 | } |
| @@ -2136,20 +2148,8 @@ Both X and Y must be numbers or markers.") | |||
| 2136 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (y, 1); | 2148 | CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (y, 1); |
| 2137 | 2149 | ||
| 2138 | if (FLOATP (x) || FLOATP (y)) | 2150 | if (FLOATP (x) || FLOATP (y)) |
| 2139 | { | 2151 | return fmod_float (x, y); |
| 2140 | double f1, f2; | 2152 | |
| 2141 | |||
| 2142 | f1 = FLOATP (x) ? XFLOAT (x)->data : XINT (x); | ||
| 2143 | f2 = FLOATP (y) ? XFLOAT (y)->data : XINT (y); | ||
| 2144 | if (f2 == 0) | ||
| 2145 | Fsignal (Qarith_error, Qnil); | ||
| 2146 | |||
| 2147 | f1 = fmod (f1, f2); | ||
| 2148 | /* If the "remainder" comes out with the wrong sign, fix it. */ | ||
| 2149 | if (f2 < 0 ? f1 > 0 : f1 < 0) | ||
| 2150 | f1 += f2; | ||
| 2151 | return (make_float (f1)); | ||
| 2152 | } | ||
| 2153 | #else /* not LISP_FLOAT_TYPE */ | 2153 | #else /* not LISP_FLOAT_TYPE */ |
| 2154 | CHECK_NUMBER_COERCE_MARKER (x, 0); | 2154 | CHECK_NUMBER_COERCE_MARKER (x, 0); |
| 2155 | CHECK_NUMBER_COERCE_MARKER (y, 1); | 2155 | CHECK_NUMBER_COERCE_MARKER (y, 1); |