mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 12:20:26 +02:00
More of:
* numbers.c, numbers.h (scm_log, scm_log10, scm_exp, scm_sqrt): New functions.
This commit is contained in:
parent
10a7fe4c1a
commit
c82f332e1e
1 changed files with 16 additions and 3 deletions
|
@ -70,10 +70,13 @@
|
|||
|
||||
#include "libguile/discouraged.h"
|
||||
|
||||
/* value per glibc, if not already defined */
|
||||
/* values per glibc, if not already defined */
|
||||
#ifndef M_LOG10E
|
||||
#define M_LOG10E 0.43429448190325182765
|
||||
#endif
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
@ -6028,7 +6031,12 @@ SCM_DEFINE (scm_log, "log", 1, 0, 0,
|
|||
{
|
||||
/* ENHANCE-ME: When z is a bignum the logarithm will fit a double
|
||||
although the value itself overflows. */
|
||||
return scm_from_double (log (scm_to_double (z)));
|
||||
double re = scm_to_double (z);
|
||||
double l = log (fabs (re));
|
||||
if (re >= 0.0)
|
||||
return scm_from_double (l);
|
||||
else
|
||||
return scm_c_make_rectangular (l, M_PI);
|
||||
}
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
@ -6054,7 +6062,12 @@ SCM_DEFINE (scm_log10, "log10", 1, 0, 0,
|
|||
{
|
||||
/* ENHANCE-ME: When z is a bignum the logarithm will fit a double
|
||||
although the value itself overflows. */
|
||||
return scm_from_double (log10 (scm_to_double (z)));
|
||||
double re = scm_to_double (z);
|
||||
double l = log10 (fabs (re));
|
||||
if (re >= 0.0)
|
||||
return scm_from_double (l);
|
||||
else
|
||||
return scm_c_make_rectangular (l, M_LOG10E * M_PI);
|
||||
}
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue