From 48a7958c332f426851d133832314ddce394fb04e Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 22 Jul 2021 17:21:52 -0400 Subject: [PATCH] Initial numerator/denominator complex num support --- runtime.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/runtime.c b/runtime.c index bf8f48fa..97a68480 100644 --- a/runtime.c +++ b/runtime.c @@ -8437,6 +8437,13 @@ void Cyc_get_ratio(void *data, object cont, object n, int numerator) d = double_value(n); } 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) { + return_closcall1(data, cont, n); + } else { + d = 1.0; + } } else { Cyc_rt_raise2(data, "Unable to convert to ratio", n); }