Have magnitude
preserve single-precision-ness.
Found using random testing.
This commit is contained in:
parent
827fc45598
commit
86f19474ca
|
@ -1607,6 +1607,9 @@
|
||||||
(test +inf.0 magnitude 0.0+inf.0i)
|
(test +inf.0 magnitude 0.0+inf.0i)
|
||||||
(test +nan.0 magnitude +nan.0+inf.0i)
|
(test +nan.0 magnitude +nan.0+inf.0i)
|
||||||
(test +nan.0 magnitude +inf.0+nan.0i)
|
(test +nan.0 magnitude +inf.0+nan.0i)
|
||||||
|
(test +inf.f magnitude 3.0f0-inf.fi)
|
||||||
|
(test +nan.f magnitude 3.0f0+nan.fi)
|
||||||
|
(test 3.0f0 magnitude 3.0f0+0.0f0i)
|
||||||
|
|
||||||
(test 0 angle 1)
|
(test 0 angle 1)
|
||||||
(test 0 angle 1.0)
|
(test 0 angle 1.0)
|
||||||
|
|
|
@ -3804,6 +3804,21 @@ static Scheme_Object *magnitude(int argc, Scheme_Object *argv[])
|
||||||
a[0] = i;
|
a[0] = i;
|
||||||
return scheme_exact_to_inexact(1, a);
|
return scheme_exact_to_inexact(1, a);
|
||||||
}
|
}
|
||||||
|
#ifdef MZ_USE_SINGLE_FLOATS
|
||||||
|
if (SCHEME_FLTP(i)) {
|
||||||
|
float f;
|
||||||
|
f = SCHEME_FLT_VAL(i);
|
||||||
|
if (MZ_IS_POS_INFINITY((double) f)) {
|
||||||
|
if (SCHEME_FLTP(r)) { /* `r` is either a single-precision float or exact 0 */
|
||||||
|
f = SCHEME_FLT_VAL(r);
|
||||||
|
if (MZ_IS_NAN((double) f)) {
|
||||||
|
return scheme_single_nan_object;
|
||||||
|
}
|
||||||
|
return scheme_single_inf_object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (SCHEME_FLOATP(i)) {
|
if (SCHEME_FLOATP(i)) {
|
||||||
double d;
|
double d;
|
||||||
d = SCHEME_FLOAT_VAL(i);
|
d = SCHEME_FLOAT_VAL(i);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user