From f05ec973b2479bd80e9966d189f3f9931e1d0f4b Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Mon, 29 Jan 2024 14:44:11 +0000 Subject: [PATCH] switch math_abs to using fabs, saves a few bytes and fabs is used elsewhere --- src/jswrap_math.c | 5 +---- src/jswrap_math.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/jswrap_math.c b/src/jswrap_math.c index d0346cc1d1..74cd146ce9 100644 --- a/src/jswrap_math.c +++ b/src/jswrap_math.c @@ -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", diff --git a/src/jswrap_math.h b/src/jswrap_math.h index 25f83b58d7..90840ae556 100644 --- a/src/jswrap_math.h +++ b/src/jswrap_math.h @@ -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);