mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 01:07:34 +02:00
Handle complex numbers better for numerator/denominator
Peel off real part if there is no imaginary part
This commit is contained in:
parent
7eee273dde
commit
efece6a413
1 changed files with 3 additions and 2 deletions
|
@ -8438,8 +8438,9 @@ void Cyc_get_ratio(void *data, object cont, object n, int numerator)
|
|||
} else if (type_of(n) == bignum_tag) {
|
||||
d = mp_get_double(&bignum_value(n));
|
||||
} else if (type_of(n) == complex_num_tag) {
|
||||
// TODO: if i is 0, set d = real part
|
||||
if (numerator) {
|
||||
if (cimag(complex_num_value(n)) == 0.0) {
|
||||
d = creal(complex_num_value(n));
|
||||
} else if (numerator) {
|
||||
return_closcall1(data, cont, n);
|
||||
} else {
|
||||
d = 1.0;
|
||||
|
|
Loading…
Add table
Reference in a new issue