fplot: add modulus % operator
This commit is contained in:
parent
6409684518
commit
f215b660b3
|
@ -29,7 +29,7 @@ option accepts as argument the x and y ranges, in the format
|
||||||
.LR "xmin:xmax ymin:ymax".
|
.LR "xmin:xmax ymin:ymax".
|
||||||
.PP
|
.PP
|
||||||
Each function to be plotted may be a combination of the independent variable x,
|
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)
|
.IR sin (2)
|
||||||
and
|
and
|
||||||
.IR exp (2).
|
.IR exp (2).
|
||||||
|
|
|
@ -49,6 +49,7 @@ void add(void) { sp--; *sp += *(sp+1); }
|
||||||
void sub(void) { sp--; *sp -= *(sp+1); }
|
void sub(void) { sp--; *sp -= *(sp+1); }
|
||||||
void mul(void) { sp--; *sp *= *(sp+1); }
|
void mul(void) { sp--; *sp *= *(sp+1); }
|
||||||
void div(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 pot(void) { sp--; *sp = pow(*sp, *(sp+1)); }
|
||||||
void osin(void) { *sp = sin(*sp); }
|
void osin(void) { *sp = sin(*sp); }
|
||||||
void ocos(void) { *sp = cos(*sp); }
|
void ocos(void) { *sp = cos(*sp); }
|
||||||
|
@ -72,6 +73,7 @@ struct Operator {
|
||||||
"-", OBINARY, 0, 0, sub,
|
"-", OBINARY, 0, 0, sub,
|
||||||
"*", OBINARY, 0, 100, mul,
|
"*", OBINARY, 0, 100, mul,
|
||||||
"/", OBINARY, 0, 100, div,
|
"/", OBINARY, 0, 100, div,
|
||||||
|
"%", OBINARY, 0, 100, mod,
|
||||||
"^", OBINARY, 1, 200, pot,
|
"^", OBINARY, 1, 200, pot,
|
||||||
"sin", OUNARY, 0, 50, osin,
|
"sin", OUNARY, 0, 50, osin,
|
||||||
"cos", OUNARY, 0, 50, ocos,
|
"cos", OUNARY, 0, 50, ocos,
|
||||||
|
|
Loading…
Reference in a new issue