From b79051329b58110ca0e194130c7d796c1b57a1d8 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Thu, 11 Apr 2024 21:13:33 +0200 Subject: [PATCH] generate_packets.py: Use fixed-point granularity when comparing floats Reported by Marko Lindqvist See osdn #48841 Signed-off-by: Alina Lenk --- common/generate_packets.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/generate_packets.py b/common/generate_packets.py index f94bdbedb2..b088d8da5d 100755 --- a/common/generate_packets.py +++ b/common/generate_packets.py @@ -899,6 +899,11 @@ class FloatType(BasicType): super().__init__(dataio_type, public_type) self.float_factor = int(float_factor) + def get_code_cmp(self, location: Location) -> str: + return f"""\ +differ = ((int) (old->{location} * {self.float_factor}) != (int) (real_packet->{location} * {self.float_factor})); +""" + def get_code_put(self, location: Location, deep_diff: bool = False) -> str: return f"""\ e |= DIO_PUT({self.dataio_type}, &dout, &field_addr, real_packet->{location}, {self.float_factor:d}); -- 2.34.1