--- parser3/src/classes/math.C 2025/08/31 18:46:29 1.110 +++ 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.110 2025/08/31 18:46:29 moko Exp $"; +volatile const char * IDENT_MATH_C="$Id: math.C,v 1.113 2026/09/15 20:48:14 moko Exp $"; // defines @@ -111,25 +112,13 @@ static void math2(Request& r, MethodPara MATH2(pow) MATH2(atan2) -static inline uint64_t ulp_key_double(double x) { - union { double d; uint64_t u; } v = { .d = x}; - return (v.u & (1ull << 63)) ? (~v.u + 1ull) : (v.u | (1ull << 63)); -} - -static inline uint64_t ulp_distance_double(double a, double b) { - if (a == b) return 0; - uint64_t ka = ulp_key_double(a); - uint64_t kb = ulp_key_double(b); - return (ka > kb) ? (ka - kb) : (kb - ka); -} - 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=3; + 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_distance_double(a,b)<=max_ulp)); + r.write(VBool::get(ulp_eq_double(a, b, max_ulp))); } inline bool is_salt_body_char(unsigned char c) {