1
0
mirror of git://projects.qi-hardware.com/fped.git synced 2025-04-21 12:27:27 +03:00

add floor() function

This commit is contained in:
Werner Almesberger
2012-05-26 14:13:58 -03:00
parent e0351bdf73
commit 9a6c7d2742
6 changed files with 51 additions and 8 deletions

13
expr.c
View File

@@ -322,6 +322,17 @@ struct num op_minus(const struct expr *self, const struct frame *frame)
}
struct num op_floor(const struct expr *self, const struct frame *frame)
{
struct num res;
res = eval_num(self->u.op.a, frame);
if (!is_undef(res))
res.n = floor(res.n);
return res;
}
#define BINARY \
struct num a, b, res; \
\
@@ -533,7 +544,7 @@ static void vacate_op(struct expr *expr)
free(expr->u.str);
return;
}
if (expr->op == op_minus ||
if (expr->op == op_minus || expr->op == op_floor ||
expr->op == op_sin || expr->op == op_cos || expr->op == op_sqrt) {
free_expr(expr->u.op.a);
return;