32 double base = args[0].asFloat();
33 double expv = args[1].asFloat();
42 return std::abs(args[0].asInt());
43 return std::abs(args[0].asFloat());
50 return std::floor(args[0].asFloat());
57 return std::ceil(args[0].asFloat());
64 return std::round(args[0].asFloat());
70 const Value &a = args[0];
71 const Value &b = args[1];
74 int64_t ai = a.
asInt();
75 int64_t bi = b.
asInt();
90 const Value &a = args[0];
91 const Value &b = args[1];
94 int64_t ai = a.
asInt();
95 int64_t bi = b.
asInt();
96 return Value(ai > bi ? ai : bi);
102 return Value(af > bf ? af : bf);
104 return a > b ? a : b;
110 return asm_log(args[0].asFloat());
116 return asm_exp(args[0].asFloat());
122 return asm_sin(args[0].asFloat());
128 return asm_cos(args[0].asFloat());
134 return asm_tan(args[0].asFloat());
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_max(const std::vector< Value > &args, VM *vm)
Maximum.
static double math_tan(const std::vector< Value > &args, VM *vm)
Tangent.
static double math_ceil(const std::vector< Value > &args, VM *vm)
Ceiling.
static void checkArgCount(const std::vector< Value > &args, size_t minimumArguments, const std::string &name, bool allowMoreArguments=false)
static double math_log(const std::vector< Value > &args, VM *vm)
Natural logarithm.
static double math_round(const std::vector< Value > &args, VM *vm)
Round.
static void registerMathFunctions(VM *vm)
static double math_sqrt(const std::vector< Value > &args, VM *vm)
Square root.
static double math_floor(const std::vector< Value > &args, VM *vm)
Floor.
static double math_cos(const std::vector< Value > &args, VM *vm)
Cosine.
static double math_exp(const std::vector< Value > &args, VM *vm)
Exponential.
static Value math_abs(const std::vector< Value > &args, VM *vm)
Absolute value.
static double math_sin(const std::vector< Value > &args, VM *vm)
Sine.
static double math_pow(const std::vector< Value > &args, VM *vm)
Power.
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.
bool isInt() const noexcept
int64_t asInt() const noexcept
Get the value as an integer.
double asFloat() const noexcept
Get the value as a double.
bool isNumber() const noexcept
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.