aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorKarl Heuer1994-02-04 20:18:59 +0000
committerKarl Heuer1994-02-04 20:18:59 +0000
commit1d66a5fabb82754741e449ed0cd7ce2bfbac6ba4 (patch)
tree7c6ec3a6ef92e5e790f76a105b8dacb7ec5a2149 /src/data.c
parent399703f129848b8267728314e2d999f0fa0767b3 (diff)
downloademacs-1d66a5fabb82754741e449ed0cd7ce2bfbac6ba4.tar.gz
emacs-1d66a5fabb82754741e449ed0cd7ce2bfbac6ba4.zip
(fmod): Implement it on systems where it's missing, using drem if available.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/data.c b/src/data.c
index c325a38a0b2..59e9e928d6e 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1778,6 +1778,19 @@ Both must be integers or markers.")
1778 return val; 1778 return val;
1779} 1779}
1780 1780
1781#ifndef HAVE_FMOD
1782double
1783fmod (f1, f2)
1784 double f1, f2;
1785{
1786#ifdef HAVE_DREM /* Some systems use this non-standard name. */
1787 return (drem (f1, f2));
1788#else /* Other systems don't seem to have it at all. */
1789 return (f1 - f2 * floor (f1/f2));
1790#endif
1791}
1792#endif /* ! HAVE_FMOD */
1793
1781DEFUN ("mod", Fmod, Smod, 2, 2, 0, 1794DEFUN ("mod", Fmod, Smod, 2, 2, 0,
1782 "Returns X modulo Y.\n\ 1795 "Returns X modulo Y.\n\
1783The result falls between zero (inclusive) and Y (exclusive).\n\ 1796The result falls between zero (inclusive) and Y (exclusive).\n\
@@ -1801,11 +1814,7 @@ Both X and Y must be numbers or markers.")
1801 if (f2 == 0) 1814 if (f2 == 0)
1802 Fsignal (Qarith_error, Qnil); 1815 Fsignal (Qarith_error, Qnil);
1803 1816
1804#ifdef HAVE_FMOD
1805 f1 = fmod (f1, f2); 1817 f1 = fmod (f1, f2);
1806#else
1807 f1 = drem (f1, f2);
1808#endif
1809 /* If the "remainder" comes out with the wrong sign, fix it. */ 1818 /* If the "remainder" comes out with the wrong sign, fix it. */
1810 if ((f1 < 0) != (f2 < 0)) 1819 if ((f1 < 0) != (f2 < 0))
1811 f1 += f2; 1820 f1 += f2;