Use log2(b) instead of (log(b) / M_LN2)
Co-Authored-By: Nobuyoshi Nakada <nobu@ruby-lang.org>
This commit is contained in:
parent
411572661a
commit
a0e6687305
Notes:
git
2023-09-13 12:40:24 +00:00
3
math.c
3
math.c
@ -538,6 +538,7 @@ math_log_split(VALUE x, size_t *numbits)
|
|||||||
# define log_intermediate log2
|
# define log_intermediate log2
|
||||||
#else
|
#else
|
||||||
# define log_intermediate log10
|
# define log_intermediate log10
|
||||||
|
double log2(double x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
@ -561,7 +562,7 @@ rb_math_log(int argc, const VALUE *argv)
|
|||||||
return DBL2NUM(-0.0);
|
return DBL2NUM(-0.0);
|
||||||
}
|
}
|
||||||
d = log_intermediate(d) / log_intermediate(b);
|
d = log_intermediate(d) / log_intermediate(b);
|
||||||
d += (numbits - numbits_2) * M_LN2 / log(b);
|
d += (numbits - numbits_2) / log2(b);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* check for pole error */
|
/* check for pole error */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user