summaryrefslogtreecommitdiffstats
path: root/arith.c
diff options
context:
space:
mode:
Diffstat (limited to 'arith.c')
-rw-r--r--arith.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/arith.c b/arith.c
index 5c17048d..769da0d0 100644
--- a/arith.c
+++ b/arith.c
@@ -1157,6 +1157,21 @@ val int_flo(val f)
}
}
+val flo_int(val i)
+{
+ if (fixnump(i))
+ return flo(c_num(i));
+
+ {
+ double d;
+ type_check(i, BGNUM);
+ if (mp_to_double(mp(i), &d) != MP_OKAY)
+ uw_throwf(error_s, lit("flo-int: bignum to float conversion failed"),
+ nao);
+ return flo(d);
+ }
+}
+
void arith_init(void)
{
mp_init(&NUM_MAX_MP);