From d3227d14528185524ffbcd162e0720ca44f56001 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 21 Dec 2018 07:54:57 +0000 Subject: [PATCH] filled moo_makefpdec() --- moo/lib/number.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/moo/lib/number.c b/moo/lib/number.c index 173a2b8..c40ef90 100644 --- a/moo/lib/number.c +++ b/moo/lib/number.c @@ -27,9 +27,20 @@ #include "moo-prv.h" #define MOO_IS_FPDEC(moo, x) (MOO_OBJ_GET_CLASS(x) == (moo)->_fixed_point_decimal) -moo_oop_t moo_makefpdec (moo_t* moo, moo_oop_t value, moo_oop_t scale) + +moo_oop_t moo_makefpdec (moo_t* moo, moo_oop_t value, moo_ooi_t scale) { - /* TODO: */ + moo_oop_fpdec_t fpdec; + + moo_pushtmp (moo, &value); + fpdec = (moo_oop_fpdec_t)moo_instantiate(moo, moo->_fixed_point_decimal, MOO_NULL, 0); + moo_poptmp (moo); + if (!fpdec) return MOO_NULL; + + MOO_STORE_OOP (moo, &fpdec->value, value); + fpdec->scale = MOO_SMOOI_TO_OOP(scale); + + return (moo_oop_t)fpdec; } static moo_ooi_t equalize_scale (moo_t* moo, moo_oop_t* x, moo_oop_t* y)