~arivigo/scalc

3ac4e521cc2f999b907bd544662a44a4f449e147 — Ariadna Vigo a month ago c4e2349
op.c: added todeg and torad conversion ops
1 files changed, 16 insertions(+), 0 deletions(-)

M op.c
M op.c => op.c +16 -0
@@ 46,6 46,8 @@ static double op_csc(double n);
static double op_acot(double n);
static double op_asec(double n);
static double op_acsc(double n);
static double op_todeg(double n);
static double op_torad(double n);

/* Constants */
static double op_cst_e(void);


@@ 77,6 79,8 @@ const OpReg op_defs[] = {
	{ "acot", 1, { .n1 = op_acot } },
	{ "asec", 1, { .n1 = op_asec } },
	{ "acsc", 1, { .n1 = op_acsc } },
	{ "todeg", 1, { .n1 = op_todeg } },
	{ "torad", 1, { .n1 = op_torad } },
	{ "e", 0, { .n0 = op_cst_e } },
	{ "pi", 0, { .n0 = op_cst_pi } },
	{ "", -1, { .n0 = NULL } } /* Dummy "terminator" entry */


@@ 182,6 186,18 @@ op_acsc(double n)
}

static double
op_todeg(double n)
{
	return n * 180 / op_cst_pi();
}

static double
op_torad(double n)
{
	return n * op_cst_pi() / 180;
}

static double
op_cst_e(void)
{
	return OP_E;