mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 14:00:21 +02:00
(scm_divide): Correction to 1/complex and <any>/complex,
need to test abs(re)<abs(im) for choice of cases, otherwise divide by zero when re==0 and im<0. Reported by Jean Crepeau.
This commit is contained in:
parent
597052a27b
commit
4c6e36a6e3
1 changed files with 3 additions and 3 deletions
|
@ -4622,7 +4622,7 @@ scm_i_divide (SCM x, SCM y, int inexact)
|
|||
{
|
||||
double r = SCM_COMPLEX_REAL (x);
|
||||
double i = SCM_COMPLEX_IMAG (x);
|
||||
if (r <= i)
|
||||
if (fabs(r) <= fabs(i))
|
||||
{
|
||||
double t = r / i;
|
||||
double d = i * (1.0 + t * t);
|
||||
|
@ -4694,7 +4694,7 @@ scm_i_divide (SCM x, SCM y, int inexact)
|
|||
{
|
||||
double r = SCM_COMPLEX_REAL (y);
|
||||
double i = SCM_COMPLEX_IMAG (y);
|
||||
if (r <= i)
|
||||
if (fabs(r) <= fabs(i))
|
||||
{
|
||||
double t = r / i;
|
||||
double d = i * (1.0 + t * t);
|
||||
|
@ -4899,7 +4899,7 @@ scm_i_divide (SCM x, SCM y, int inexact)
|
|||
{
|
||||
double ry = SCM_COMPLEX_REAL (y);
|
||||
double iy = SCM_COMPLEX_IMAG (y);
|
||||
if (ry <= iy)
|
||||
if (fabs(ry) <= fabs(iy))
|
||||
{
|
||||
double t = ry / iy;
|
||||
double d = iy * (1.0 + t * t);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue