Skip to content

Commit

Permalink
switch math_abs to using fabs, saves a few bytes and fabs is used els…
Browse files Browse the repository at this point in the history
…ewhere
  • Loading branch information
gfwilliams committed Jan 29, 2024
1 parent f58c541 commit f05ec97
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 1 addition & 4 deletions src/jswrap_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,12 @@ This is a standard JavaScript class that contains useful Maths routines
"type" : "staticmethod",
"class" : "Math",
"name" : "abs",
"generate" : "jswrap_math_abs",
"generate" : "fabs",
"params" : [
["x","float","A floating point value"]
],
"return" : ["float","The absolute value of x (eg, ```Math.abs(2)==2```, but also ```Math.abs(-2)==2```)"]
}*/
JsVarFloat jswrap_math_abs(JsVarFloat x) {
return (x<0)?-x:x;
}
/*JSON{
"type" : "staticmethod",
"ifndef" : "SAVE_ON_FLASH_EXTREME",
Expand Down
1 change: 0 additions & 1 deletion src/jswrap_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@


JsVarInt jswrap_integer_valueOf(JsVar *v);
JsVarFloat jswrap_math_abs(JsVarFloat x);
JsVarFloat jswrap_math_asin(JsVarFloat x);
double jswrap_math_mod(double x, double y);
double jswrap_math_pow(double x, double y);
Expand Down

0 comments on commit f05ec97

Please sign in to comment.