From cb05c8142dec7aa7c577081cd3344d05e52fc37d Mon Sep 17 00:00:00 2001 From: Alain BKR Date: Sun, 7 May 2023 05:10:53 +0300 Subject: [PATCH 24/24] Relax ADV_WANTS_EQ Relative comparison See osdn #47973 --- common/fc_types.h | 2 -- server/advisors/advtools.h | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/fc_types.h b/common/fc_types.h index f61e950174..91dc81d50f 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -969,8 +969,6 @@ enum spaceship_place_type { #define SPECENUM_VALUE2NAME "Nation" #include "specenum_gen.h" -#define FC_EPSILON (0.000001) - typedef float adv_want; #define ADV_WANT_PRINTF "%f" diff --git a/server/advisors/advtools.h b/server/advisors/advtools.h index b357fbbe64..4c741a1040 100644 --- a/server/advisors/advtools.h +++ b/server/advisors/advtools.h @@ -18,7 +18,9 @@ #define MORT 24 -#define ADV_WANTS_EQ(_w1, _w2) (fabs((_w1) - (_w2)) < FC_EPSILON) +/* relative comparison for equality of floats */ +#define FC_EPSILON (0.001) +#define ADV_WANTS_EQ(_w1, _w2) (fabs((_w1) - (_w2)) < FC_EPSILON * (fabs((float) (_w1)) + fabs((float) (_w2)))) adv_want amortize(adv_want benefit, int delay); -- 2.39.2