diff --git a/moo/kernel/Magnitu.moo b/moo/kernel/Magnitu.moo index a2e386c..75088cc 100644 --- a/moo/kernel/Magnitu.moo +++ b/moo/kernel/Magnitu.moo @@ -126,6 +126,18 @@ class(#limited) Number(Magnitude) self primitiveFailed. } + method mul: aNumber + { + + self primitiveFailed. + } + + method mlt: aNumber + { + + self primitiveFailed. + } + method div: aNumber { ## integer division rounded toward zero diff --git a/moo/kernel/test-001.moo b/moo/kernel/test-001.moo index c55aead..832d97b 100644 --- a/moo/kernel/test-001.moo +++ b/moo/kernel/test-001.moo @@ -208,8 +208,6 @@ extend MyObject [ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ], [ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ], - - ## 60-64 [ (-0.1233 * 999999.123) = -123299.8918 ], [ (-0.1233 * 999999.123) asString = '-123299.8918' ], @@ -218,6 +216,8 @@ extend MyObject [ (1.234 - 1.234) = 0 ], ## 0.000 ## 65-69 + [ (10.12 * 20.345) = 205.891 ], + [ (10.12 mlt: 20.345) = 205.89 ], [ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ], [ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ], diff --git a/moo/lib/exec.c b/moo/lib/exec.c index 5db44e0..973b808 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -2870,6 +2870,22 @@ static moo_pfrc_t pf_number_mul (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) return MOO_PF_SUCCESS; } +static moo_pfrc_t pf_number_mlt (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) +{ + moo_oop_t rcv, arg, res; + + MOO_ASSERT (moo, nargs == 1); + + rcv = MOO_STACK_GETRCV(moo, nargs); + arg = MOO_STACK_GETARG(moo, nargs, 0); + + res = moo_mltnums(moo, rcv, arg); + if (!res) return (moo->errnum == MOO_EINVAL? MOO_PF_FAILURE: MOO_PF_HARD_FAILURE); + + MOO_STACK_SETRET (moo, nargs, res); + return MOO_PF_SUCCESS; +} + static moo_pfrc_t pf_number_div (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) { moo_oop_t rcv, arg, res; @@ -3873,6 +3889,7 @@ static pf_t pftab[] = { "_number_le", { pf_number_le, 1, 1 } }, { "_number_lt", { pf_number_lt, 1, 1 } }, { "_number_mdiv", { pf_number_mdiv, 1, 1 } }, + { "_number_mlt", { pf_number_mlt, 1, 1 } }, { "_number_mul", { pf_number_mul, 1, 1 } }, { "_number_ne", { pf_number_ne, 1, 1 } }, { "_number_negated", { pf_number_negated, 0, 0 } },