--- parser3/src/classes/math.C 2024/12/06 21:43:35 1.109 +++ parser3/src/classes/math.C 2026/09/15 20:48:14 1.113 @@ -1,7 +1,7 @@ /** @file Parser: @b math parser class. - Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) Authors: Konstantin Morshnev , Alexandr Petrosian portions from gen_uuid.c, @@ -10,6 +10,7 @@ #include "pa_vmethod_frame.h" #include "pa_common.h" +#include "pa_int.h" #include "pa_base64.h" #include "pa_vint.h" #include "pa_vmath.h" @@ -23,7 +24,7 @@ extern "C" char *crypt(const char* , const char* ); #endif -volatile const char * IDENT_MATH_C="$Id: math.C,v 1.109 2024/12/06 21:43:35 moko Exp $"; +volatile const char * IDENT_MATH_C="$Id: math.C,v 1.113 2026/09/15 20:48:14 moko Exp $"; // defines @@ -111,6 +112,15 @@ static void math2(Request& r, MethodPara MATH2(pow) MATH2(atan2) +static void _eq(Request& r, MethodParams& params) { + double a=params.as_double(0, "parameter must be expression", r); + double b=params.as_double(1, "parameter must be expression", r); + uint64_t max_ulp=ULP_EQ_DEFAULT_DIST; + if(params.count() == 3) + max_ulp=params.as_int(2, "max distance must be integer", r); + r.write(VBool::get(ulp_eq_double(a, b, max_ulp))); +} + inline bool is_salt_body_char(unsigned char c) { return pa_isalnum(c) || c == '.' || c=='/'; } @@ -768,6 +778,9 @@ MMath::MMath(): Methoded("math") { // ^math:pow(x;y) ADDN(pow, 2); + // ^math:eq(a;b[;precision]) + add_native_method("eq", Method::CT_STATIC, _eq, 2, 3); + // ^math:crypt[password;salt] ADDN(crypt, 2);