forked from Mirror/wren
Add .pow(_) to Num
This commit is contained in:
@ -644,6 +644,11 @@ DEF_PRIMITIVE(num_atan2)
|
||||
RETURN_NUM(atan2(AS_NUM(args[0]), AS_NUM(args[1])));
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(num_pow)
|
||||
{
|
||||
RETURN_NUM(pow(AS_NUM(args[0]), AS_NUM(args[1])));
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(num_fraction)
|
||||
{
|
||||
double dummy;
|
||||
@ -1272,6 +1277,7 @@ void wrenInitializeCore(WrenVM* vm)
|
||||
PRIMITIVE(vm->numClass, "..(_)", num_dotDot);
|
||||
PRIMITIVE(vm->numClass, "...(_)", num_dotDotDot);
|
||||
PRIMITIVE(vm->numClass, "atan(_)", num_atan2);
|
||||
PRIMITIVE(vm->numClass, "pow(_)", num_pow);
|
||||
PRIMITIVE(vm->numClass, "fraction", num_fraction);
|
||||
PRIMITIVE(vm->numClass, "isInfinity", num_isInfinity);
|
||||
PRIMITIVE(vm->numClass, "isInteger", num_isInteger);
|
||||
|
||||
4
test/core/number/pow.wren
Normal file
4
test/core/number/pow.wren
Normal file
@ -0,0 +1,4 @@
|
||||
System.print(2.pow(4)) // expect: 16
|
||||
System.print(2.pow(10)) // expect: 1024
|
||||
|
||||
System.print(1.pow(0)) // expect: 1
|
||||
Reference in New Issue
Block a user