forked from Mirror/wren
Merge branch 'num-features' of https://github.com/underscorediscovery/wren into underscorediscovery-num-features
This commit is contained in:
1
AUTHORS
1
AUTHORS
@ -18,3 +18,4 @@ Alexander Roper <minirop@gmail.com>
|
||||
Will Speak <will@willspeak.me>
|
||||
Damien Radtke <damienradtke@gmail.com>
|
||||
Max Ferguson <maxxferguson@gmail.com>
|
||||
Sven Bergström <sven@underscorediscovery.com>
|
||||
|
||||
@ -596,6 +596,7 @@ DEF_NUM_FN(negate, -)
|
||||
DEF_NUM_FN(sin, sin)
|
||||
DEF_NUM_FN(sqrt, sqrt)
|
||||
DEF_NUM_FN(tan, tan)
|
||||
DEF_NUM_FN(log, log)
|
||||
|
||||
DEF_PRIMITIVE(num_mod)
|
||||
{
|
||||
@ -644,6 +645,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;
|
||||
@ -1267,11 +1273,13 @@ void wrenInitializeCore(WrenVM* vm)
|
||||
PRIMITIVE(vm->numClass, "sin", num_sin);
|
||||
PRIMITIVE(vm->numClass, "sqrt", num_sqrt);
|
||||
PRIMITIVE(vm->numClass, "tan", num_tan);
|
||||
PRIMITIVE(vm->numClass, "log", num_log);
|
||||
PRIMITIVE(vm->numClass, "%(_)", num_mod);
|
||||
PRIMITIVE(vm->numClass, "~", num_bitwiseNot);
|
||||
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);
|
||||
|
||||
3
test/core/number/log.wren
Normal file
3
test/core/number/log.wren
Normal file
@ -0,0 +1,3 @@
|
||||
System.print(3.log) // expect: 1.0986122886681
|
||||
System.print(100.log) // expect: 4.6051701859881
|
||||
System.print((-1).log) // expect: nan
|
||||
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