diff --git a/sys/man/1/fplot b/sys/man/1/fplot index 9c66d9119..75329a989 100644 --- a/sys/man/1/fplot +++ b/sys/man/1/fplot @@ -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). diff --git a/sys/src/cmd/fplot.c b/sys/src/cmd/fplot.c index 866901135..af5564f7d 100644 --- a/sys/src/cmd/fplot.c +++ b/sys/src/cmd/fplot.c @@ -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,