Commit 44bf8dc4 authored by Andrey Zhezherun's avatar Andrey Zhezherun Committed by Alexandre Julliard

msvcp: Fixed complex division.

parent 3bb2c117
...@@ -1087,6 +1087,7 @@ complex_float* __cdecl complex_float_add_cf(complex_float *ret, const complex_fl ...@@ -1087,6 +1087,7 @@ complex_float* __cdecl complex_float_add_cf(complex_float *ret, const complex_fl
/* ??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z */ /* ??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z */
complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float *l, const complex_float *r) complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float *l, const complex_float *r)
{ {
float tmp, den;
if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag) if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag)
|| _isnan(r->real) || _isnan(r->imag)) { || _isnan(r->real) || _isnan(r->imag)) {
ret->real = std_numeric_limits_float_quiet_NaN(); ret->real = std_numeric_limits_float_quiet_NaN();
...@@ -1094,15 +1095,16 @@ complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float ...@@ -1094,15 +1095,16 @@ complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float
return ret; return ret;
} }
ret->real = 0; if (fabsf(r->real) >= fabsf(r->imag)) {
ret->imag = 0; tmp = r->imag / r->real;
if(r->real) { den = r->real + r->imag*tmp;
ret->real = l->real / r->real; ret->real = (l->real + l->imag*tmp) / den;
ret->imag = l->imag / r->real; ret->imag = (l->imag - l->real*tmp) / den;
} } else {
if(r->imag) { tmp = r->real / r->imag;
ret->real += l->imag / r->imag; den = r->real*tmp + r->imag;
ret->imag -= l->real / r->imag; ret->real = (l->real*tmp + l->imag) / den;
ret->imag = (l->imag*tmp - l->real) / den;
} }
return ret; return ret;
} }
...@@ -1705,6 +1707,7 @@ complex_double* __cdecl complex_double_add_cd(complex_double *ret, const complex ...@@ -1705,6 +1707,7 @@ complex_double* __cdecl complex_double_add_cd(complex_double *ret, const complex
/* ??$?KO@std@@YA?AV?$complex@O@0@AEBV10@0@Z */ /* ??$?KO@std@@YA?AV?$complex@O@0@AEBV10@0@Z */
complex_double* __cdecl complex_double_div(complex_double *ret, const complex_double *l, const complex_double *r) complex_double* __cdecl complex_double_div(complex_double *ret, const complex_double *l, const complex_double *r)
{ {
double tmp, den;
if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag) if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag)
|| _isnan(r->real) || _isnan(r->imag)) { || _isnan(r->real) || _isnan(r->imag)) {
ret->real = std_numeric_limits_double_quiet_NaN(); ret->real = std_numeric_limits_double_quiet_NaN();
...@@ -1712,15 +1715,16 @@ complex_double* __cdecl complex_double_div(complex_double *ret, const complex_do ...@@ -1712,15 +1715,16 @@ complex_double* __cdecl complex_double_div(complex_double *ret, const complex_do
return ret; return ret;
} }
ret->real = 0; if (fabs(r->real) >= fabs(r->imag)) {
ret->imag = 0; tmp = r->imag / r->real;
if(r->real) { den = r->real + r->imag*tmp;
ret->real = l->real / r->real; ret->real = (l->real + l->imag*tmp) / den;
ret->imag = l->imag / r->real; ret->imag = (l->imag - l->real*tmp) / den;
} } else {
if(r->imag) { tmp = r->real / r->imag;
ret->real += l->imag / r->imag; den = r->real*tmp + r->imag;
ret->imag -= l->real / r->imag; ret->real = (l->real*tmp + l->imag) / den;
ret->imag = (l->imag*tmp - l->real) / den;
} }
return ret; return ret;
} }
......
...@@ -1087,6 +1087,7 @@ complex_float* __cdecl complex_float_add_cf(complex_float *ret, const complex_fl ...@@ -1087,6 +1087,7 @@ complex_float* __cdecl complex_float_add_cf(complex_float *ret, const complex_fl
/* ??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z */ /* ??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z */
complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float *l, const complex_float *r) complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float *l, const complex_float *r)
{ {
float tmp, den;
if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag) if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag)
|| _isnan(r->real) || _isnan(r->imag)) { || _isnan(r->real) || _isnan(r->imag)) {
ret->real = std_numeric_limits_float_quiet_NaN(); ret->real = std_numeric_limits_float_quiet_NaN();
...@@ -1094,15 +1095,16 @@ complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float ...@@ -1094,15 +1095,16 @@ complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float
return ret; return ret;
} }
ret->real = 0; if (fabsf(r->real) >= fabsf(r->imag)) {
ret->imag = 0; tmp = r->imag / r->real;
if(r->real) { den = r->real + r->imag*tmp;
ret->real = l->real / r->real; ret->real = (l->real + l->imag*tmp) / den;
ret->imag = l->imag / r->real; ret->imag = (l->imag - l->real*tmp) / den;
} } else {
if(r->imag) { tmp = r->real / r->imag;
ret->real += l->imag / r->imag; den = r->real*tmp + r->imag;
ret->imag -= l->real / r->imag; ret->real = (l->real*tmp + l->imag) / den;
ret->imag = (l->imag*tmp - l->real) / den;
} }
return ret; return ret;
} }
...@@ -1705,6 +1707,7 @@ complex_double* __cdecl complex_double_add_cd(complex_double *ret, const complex ...@@ -1705,6 +1707,7 @@ complex_double* __cdecl complex_double_add_cd(complex_double *ret, const complex
/* ??$?KO@std@@YA?AV?$complex@O@0@AEBV10@0@Z */ /* ??$?KO@std@@YA?AV?$complex@O@0@AEBV10@0@Z */
complex_double* __cdecl complex_double_div(complex_double *ret, const complex_double *l, const complex_double *r) complex_double* __cdecl complex_double_div(complex_double *ret, const complex_double *l, const complex_double *r)
{ {
double tmp, den;
if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag) if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag)
|| _isnan(r->real) || _isnan(r->imag)) { || _isnan(r->real) || _isnan(r->imag)) {
ret->real = std_numeric_limits_double_quiet_NaN(); ret->real = std_numeric_limits_double_quiet_NaN();
...@@ -1712,15 +1715,16 @@ complex_double* __cdecl complex_double_div(complex_double *ret, const complex_do ...@@ -1712,15 +1715,16 @@ complex_double* __cdecl complex_double_div(complex_double *ret, const complex_do
return ret; return ret;
} }
ret->real = 0; if (fabs(r->real) >= fabs(r->imag)) {
ret->imag = 0; tmp = r->imag / r->real;
if(r->real) { den = r->real + r->imag*tmp;
ret->real = l->real / r->real; ret->real = (l->real + l->imag*tmp) / den;
ret->imag = l->imag / r->real; ret->imag = (l->imag - l->real*tmp) / den;
} } else {
if(r->imag) { tmp = r->real / r->imag;
ret->real += l->imag / r->imag; den = r->real*tmp + r->imag;
ret->imag -= l->real / r->imag; ret->real = (l->real*tmp + l->imag) / den;
ret->imag = (l->imag*tmp - l->real) / den;
} }
return ret; return ret;
} }
......
...@@ -1087,6 +1087,7 @@ complex_float* __cdecl complex_float_add_cf(complex_float *ret, const complex_fl ...@@ -1087,6 +1087,7 @@ complex_float* __cdecl complex_float_add_cf(complex_float *ret, const complex_fl
/* ??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z */ /* ??$?KM@std@@YA?AV?$complex@M@0@AEBV10@0@Z */
complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float *l, const complex_float *r) complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float *l, const complex_float *r)
{ {
float tmp, den;
if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag) if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag)
|| _isnan(r->real) || _isnan(r->imag)) { || _isnan(r->real) || _isnan(r->imag)) {
ret->real = std_numeric_limits_float_quiet_NaN(); ret->real = std_numeric_limits_float_quiet_NaN();
...@@ -1094,15 +1095,16 @@ complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float ...@@ -1094,15 +1095,16 @@ complex_float* __cdecl complex_float_div(complex_float *ret, const complex_float
return ret; return ret;
} }
ret->real = 0; if (fabsf(r->real) >= fabsf(r->imag)) {
ret->imag = 0; tmp = r->imag / r->real;
if(r->real) { den = r->real + r->imag*tmp;
ret->real = l->real / r->real; ret->real = (l->real + l->imag*tmp) / den;
ret->imag = l->imag / r->real; ret->imag = (l->imag - l->real*tmp) / den;
} } else {
if(r->imag) { tmp = r->real / r->imag;
ret->real += l->imag / r->imag; den = r->real*tmp + r->imag;
ret->imag -= l->real / r->imag; ret->real = (l->real*tmp + l->imag) / den;
ret->imag = (l->imag*tmp - l->real) / den;
} }
return ret; return ret;
} }
...@@ -1705,6 +1707,7 @@ complex_double* __cdecl complex_double_add_cd(complex_double *ret, const complex ...@@ -1705,6 +1707,7 @@ complex_double* __cdecl complex_double_add_cd(complex_double *ret, const complex
/* ??$?KO@std@@YA?AV?$complex@O@0@AEBV10@0@Z */ /* ??$?KO@std@@YA?AV?$complex@O@0@AEBV10@0@Z */
complex_double* __cdecl complex_double_div(complex_double *ret, const complex_double *l, const complex_double *r) complex_double* __cdecl complex_double_div(complex_double *ret, const complex_double *l, const complex_double *r)
{ {
double tmp, den;
if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag) if((!r->real && !r->imag) || _isnan(l->real) || _isnan(l->imag)
|| _isnan(r->real) || _isnan(r->imag)) { || _isnan(r->real) || _isnan(r->imag)) {
ret->real = std_numeric_limits_double_quiet_NaN(); ret->real = std_numeric_limits_double_quiet_NaN();
...@@ -1712,15 +1715,16 @@ complex_double* __cdecl complex_double_div(complex_double *ret, const complex_do ...@@ -1712,15 +1715,16 @@ complex_double* __cdecl complex_double_div(complex_double *ret, const complex_do
return ret; return ret;
} }
ret->real = 0; if (fabs(r->real) >= fabs(r->imag)) {
ret->imag = 0; tmp = r->imag / r->real;
if(r->real) { den = r->real + r->imag*tmp;
ret->real = l->real / r->real; ret->real = (l->real + l->imag*tmp) / den;
ret->imag = l->imag / r->real; ret->imag = (l->imag - l->real*tmp) / den;
} } else {
if(r->imag) { tmp = r->real / r->imag;
ret->real += l->imag / r->imag; den = r->real*tmp + r->imag;
ret->imag -= l->real / r->imag; ret->real = (l->real*tmp + l->imag) / den;
ret->imag = (l->imag*tmp - l->real) / den;
} }
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment