35 double base = args[0].asFloat();
36 double expv = args[1].asFloat();
45 return std::abs(args[0].asInt());
46 return std::abs(args[0].asFloat());
53 return static_cast<int64_t
>(std::floor(args[0].asFloat()));
60 return static_cast<int64_t
>(std::ceil(args[0].asFloat()));
67 return static_cast<int64_t
>(std::round(args[0].asFloat()));
73 const Value &a = args[0];
74 const Value &b = args[1];
77 int64_t ai = a.
asInt();
78 int64_t bi = b.
asInt();
93 const Value &a = args[0];
94 const Value &b = args[1];
97 int64_t ai = a.
asInt();
98 int64_t bi = b.
asInt();
99 return Value(ai > bi ? ai : bi);
105 return Value(af > bf ? af : bf);
107 return a > b ? a : b;
double asm_tan(double a)
Native tangent.
double asm_log(double a)
Native natural logarithm.
double asm_sqrt(double a)
Native square root.
double asm_sin(double a)
Native sine.
double asm_exp(double a)
Native exponential.
double asm_cos(double a)
Native cosine.
double asm_pow(double a, double b)
Native power.
static Value math_sin(const std::vector< Value > &args, VM *vm)
Sine.
static Value math_max(const std::vector< Value > &args, VM *vm)
Maximum.
static Value math_floor(const std::vector< Value > &args, VM *vm)
Floor.
static Value math_ceil(const std::vector< Value > &args, VM *vm)
Ceiling.
static Value math_round(const std::vector< Value > &args, VM *vm)
Round.
static Value registerMathFunctions(const std::vector< Value > &args, VM *vm)
static void checkArgCount(const std::vector< Value > &args, size_t minimumArguments, const std::string &name, bool allowMoreArguments=false)
static Value math_pow(const std::vector< Value > &args, VM *vm)
Power.
static Value math_tan(const std::vector< Value > &args, VM *vm)
Tangent.
static Value math_log(const std::vector< Value > &args, VM *vm)
Natural logarithm.
static Value math_exp(const std::vector< Value > &args, VM *vm)
Exponential.
static Value math_cos(const std::vector< Value > &args, VM *vm)
Cosine.
static Value math_abs(const std::vector< Value > &args, VM *vm)
Absolute value.
static Value math_sqrt(const std::vector< Value > &args, VM *vm)
Square root.
static Value math_min(const std::vector< Value > &args, VM *vm)
Minimum.
void registerNativeFunction(const std::string &name, NativeFunction fn)
Register a native function.
A value in the Phasor VM.
double asFloat() const
Get the value as a double.
bool isNumber() const
Check if the value is a number.
int64_t asInt() const
Get the value as an integer.
bool isInt() const
Check if the value is an integer.
int64_t asm_iless_than(int64_t a, int64_t b)
Native Less than comparison.
int64_t asm_flless_than(double a, double b)
The Phasor Programming Language and Runtime.