forked from Mirror/wren
Merge branch 'num-properties' of https://github.com/Nelarius/wren into Nelarius-num-properties
This commit is contained in:
@ -13,6 +13,14 @@ It is a runtime error if `value` is not a string.
|
||||
|
||||
The value of π.
|
||||
|
||||
### Num.**largest**
|
||||
|
||||
The highest representable value of `Num`.
|
||||
|
||||
### Num.**smallest**
|
||||
|
||||
The difference between 1.0 and the next representable value for `Num`.
|
||||
|
||||
## Methods
|
||||
|
||||
### **abs**
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@ -683,6 +684,16 @@ DEF_PRIMITIVE(num_sign)
|
||||
}
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(num_largest)
|
||||
{
|
||||
RETURN_NUM(DBL_MAX);
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(num_smallest)
|
||||
{
|
||||
RETURN_NUM(DBL_EPSILON);
|
||||
}
|
||||
|
||||
DEF_PRIMITIVE(num_toString)
|
||||
{
|
||||
RETURN_VAL(wrenNumToString(vm, AS_NUM(args[0])));
|
||||
@ -1230,6 +1241,8 @@ void wrenInitializeCore(WrenVM* vm)
|
||||
vm->numClass = AS_CLASS(wrenFindVariable(vm, coreModule, "Num"));
|
||||
PRIMITIVE(vm->numClass->obj.classObj, "fromString(_)", num_fromString);
|
||||
PRIMITIVE(vm->numClass->obj.classObj, "pi", num_pi);
|
||||
PRIMITIVE(vm->numClass->obj.classObj, "largest", num_largest);
|
||||
PRIMITIVE(vm->numClass->obj.classObj, "smallest", num_smallest);
|
||||
PRIMITIVE(vm->numClass, "-(_)", num_minus);
|
||||
PRIMITIVE(vm->numClass, "+(_)", num_plus);
|
||||
PRIMITIVE(vm->numClass, "*(_)", num_multiply);
|
||||
|
||||
Reference in New Issue
Block a user