return 0;
}
+static int qc_pow(qc_program_t *prog) {
+ qcany_t *base, *exp, out;
+ CheckArgs(2);
+ base = GetArg(0);
+ exp = GetArg(1);
+ out._float = pow(base->_float, exp->_float);
+ Return(out);
+ return 0;
+}
+
static prog_builtin_t qc_builtins[] = {
NULL,
&qc_print, /* 1 */
&qc_strcmp, /* 11 */
&qc_normalize, /* 12 */
&qc_sqrt, /* 13 */
- &qc_floor /* 14 */
+ &qc_floor, /* 14 */
+ &qc_pow /* 15 */
};
static const char *arg0 = NULL;
vector (vector) normalize = #12;
float (float) sqrt = #13;
float (float) floor = #14;
+float (float, float) pow = #15;
-float pow(float x, float y) {
- return __builtin_pow(x, y);
-}
-
void main() {
- float hundy = pow(10, 2); // 10^2 == 100
+ float hundy = __builtin_pow(10, 2); // 10^2 == 100
print(ftos(hundy), "\n"); // prints: 100
+ hundy = pow(10, 2);
+ print(ftos(hundy), "\n");
+
hundy -= 90; // 100-90 = 10
print(ftos(hundy ** 2), "\n"); // prints: 100
+ print(ftos(pow(hundy, 2)), "\n"); // prints: 100
hundy = 10.0f;
print(ftos(__builtin_exp(hundy)), "\n"); // prints: 22026.5