mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
Issue #510 - Exact support for complex nums
Allow `exact` to properly handle complex numbers
This commit is contained in:
parent
e8ba3f1c1b
commit
7dc1f9e179
2 changed files with 10 additions and 2 deletions
|
@ -517,7 +517,10 @@ int Cyc_have_mstreams();
|
|||
} else if (type_of(z) == bignum_tag) { \
|
||||
return_closcall1(data, cont, z); \
|
||||
} else if (type_of(z) == complex_num_tag) { \
|
||||
return_closcall1(data, cont, z); \
|
||||
double dreal = OP(creal(((complex_num_type *) z)->value)); \
|
||||
double dimag = OP(cimag(((complex_num_type *) z)->value)); \
|
||||
make_complex_num(num, dreal, dimag); \
|
||||
return_closcall1(data, cont, &num); \
|
||||
} else { \
|
||||
double d = ((double_type *)z)->value; \
|
||||
if (isnan(d)) { \
|
||||
|
@ -548,7 +551,11 @@ int Cyc_have_mstreams();
|
|||
} else if (type_of(z) == bignum_tag) { \
|
||||
return z; \
|
||||
} else if (type_of(z) == complex_num_tag) { \
|
||||
return z; \
|
||||
double dreal = OP(creal(((complex_num_type *) z)->value)); \
|
||||
double dimag = OP(cimag(((complex_num_type *) z)->value)); \
|
||||
double complex unboxed = dreal + (dimag * I); \
|
||||
assign_complex_num(ptr, unboxed); \
|
||||
return ptr; \
|
||||
} else { \
|
||||
double d = ((double_type *)z)->value; \
|
||||
if (isnan(d)) { \
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
(test -1 (exact -1.0))
|
||||
(test -1 (exact -1.1))
|
||||
(test -1 (exact -1.1))
|
||||
(test 1.0+1.0i (exact 1.1+1.2i))
|
||||
(test #t (bignum? (exact 111111111111111111111111111.0)))
|
||||
(test #t (bignum? (exact -111111111111111111111111111.0)))
|
||||
;(test +inf.0 (exact +inf.0))
|
||||
|
|
Loading…
Add table
Reference in a new issue