Added pf_number_mlt() whcih scales to the smaller of the two fixed-point numbers
This commit is contained in:
parent
9cd0b28933
commit
5101228c39
@ -126,6 +126,18 @@ class(#limited) Number(Magnitude)
|
|||||||
self primitiveFailed.
|
self primitiveFailed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
method mul: aNumber
|
||||||
|
{
|
||||||
|
<primitive: #_number_mul>
|
||||||
|
self primitiveFailed.
|
||||||
|
}
|
||||||
|
|
||||||
|
method mlt: aNumber
|
||||||
|
{
|
||||||
|
<primitive: #_number_mlt>
|
||||||
|
self primitiveFailed.
|
||||||
|
}
|
||||||
|
|
||||||
method div: aNumber
|
method div: aNumber
|
||||||
{
|
{
|
||||||
## integer division rounded toward zero
|
## integer division rounded toward zero
|
||||||
|
@ -208,8 +208,6 @@ extend MyObject
|
|||||||
[ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ],
|
[ (16r2dd01fc06c265c8163ac729b49d890939826ce3dd rem: 16r3b9aca00) = 394876893 ],
|
||||||
[ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ],
|
[ (16rFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF bitAnd: 16r1111111111111111111111111111111111111111) = 16r1111111111111111111111111111111111111111 ],
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 60-64
|
## 60-64
|
||||||
[ (-0.1233 * 999999.123) = -123299.8918 ],
|
[ (-0.1233 * 999999.123) = -123299.8918 ],
|
||||||
[ (-0.1233 * 999999.123) asString = '-123299.8918' ],
|
[ (-0.1233 * 999999.123) asString = '-123299.8918' ],
|
||||||
@ -218,6 +216,8 @@ extend MyObject
|
|||||||
[ (1.234 - 1.234) = 0 ], ## 0.000
|
[ (1.234 - 1.234) = 0 ], ## 0.000
|
||||||
|
|
||||||
## 65-69
|
## 65-69
|
||||||
|
[ (10.12 * 20.345) = 205.891 ],
|
||||||
|
[ (10.12 mlt: 20.345) = 205.89 ],
|
||||||
[ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ],
|
[ (-123897128378912738912738917.112323131233 div: 123.1) = -1006475453931053931053931.089458352000 ],
|
||||||
[ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ],
|
[ (-1006475453931053931053931.089458352000 * 123.1) = -123897128378912738912738917.112323131200 ],
|
||||||
|
|
||||||
|
@ -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;
|
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)
|
static moo_pfrc_t pf_number_div (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
|
||||||
{
|
{
|
||||||
moo_oop_t rcv, arg, res;
|
moo_oop_t rcv, arg, res;
|
||||||
@ -3873,6 +3889,7 @@ static pf_t pftab[] =
|
|||||||
{ "_number_le", { pf_number_le, 1, 1 } },
|
{ "_number_le", { pf_number_le, 1, 1 } },
|
||||||
{ "_number_lt", { pf_number_lt, 1, 1 } },
|
{ "_number_lt", { pf_number_lt, 1, 1 } },
|
||||||
{ "_number_mdiv", { pf_number_mdiv, 1, 1 } },
|
{ "_number_mdiv", { pf_number_mdiv, 1, 1 } },
|
||||||
|
{ "_number_mlt", { pf_number_mlt, 1, 1 } },
|
||||||
{ "_number_mul", { pf_number_mul, 1, 1 } },
|
{ "_number_mul", { pf_number_mul, 1, 1 } },
|
||||||
{ "_number_ne", { pf_number_ne, 1, 1 } },
|
{ "_number_ne", { pf_number_ne, 1, 1 } },
|
||||||
{ "_number_negated", { pf_number_negated, 0, 0 } },
|
{ "_number_negated", { pf_number_negated, 0, 0 } },
|
||||||
|
Loading…
Reference in New Issue
Block a user