fplot: add modulus % operator

This commit is contained in:
cinap_lenrek 2015-02-05 19:55:46 +01:00
parent 6409684518
commit f215b660b3
2 changed files with 3 additions and 1 deletions

View file

@ -29,7 +29,7 @@ option accepts as argument the x and y ranges, in the format
.LR "xmin:xmax ymin:ymax".
.PP
Each function to be plotted may be a combination of the independent variable x,
the elementary operations (+, -, *, and /), and the functions described in
the elementary operations (+, -, *, / and %), and the functions described in
.IR sin (2)
and
.IR exp (2).

View file

@ -49,6 +49,7 @@ void add(void) { sp--; *sp += *(sp+1); }
void sub(void) { sp--; *sp -= *(sp+1); }
void mul(void) { sp--; *sp *= *(sp+1); }
void div(void) { sp--; *sp /= *(sp+1); }
void mod(void) { sp--; *sp = fmod(*sp, *(sp+1)); }
void pot(void) { sp--; *sp = pow(*sp, *(sp+1)); }
void osin(void) { *sp = sin(*sp); }
void ocos(void) { *sp = cos(*sp); }
@ -72,6 +73,7 @@ struct Operator {
"-", OBINARY, 0, 0, sub,
"*", OBINARY, 0, 100, mul,
"/", OBINARY, 0, 100, div,
"%", OBINARY, 0, 100, mod,
"^", OBINARY, 1, 200, pot,
"sin", OUNARY, 0, 50, osin,
"cos", OUNARY, 0, 50, ocos,