From 66262a3b07afcec23fb9939432ac0143677a68e5 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 13 Jul 2023 09:51:56 -0400 Subject: [PATCH] Update src/app/clusters/fan-control-server/fan-control-server.cpp Co-authored-by: Boris Zbarsky --- src/app/clusters/fan-control-server/fan-control-server.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/fan-control-server/fan-control-server.cpp b/src/app/clusters/fan-control-server/fan-control-server.cpp index 4a04028e910d68..eed33820e0a947 100644 --- a/src/app/clusters/fan-control-server/fan-control-server.cpp +++ b/src/app/clusters/fan-control-server/fan-control-server.cpp @@ -347,8 +347,8 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt ChipLogError(Zcl, "Failed to get SpeedSetting with error: 0x%02x", status)); uint16_t percent = percentSetting.Value(); - // Plus 99 then devide by 100 instead of multiplying 0.01 to workaround floating point precision error - uint8_t speedSetting = static_cast(ceil((speedMax * percent + 99) / 100)); + // Plus 99 then integer divide by 100 instead of multiplying 0.01 to avoid floating point precision error + uint8_t speedSetting = static_cast((speedMax * percent + 99) / 100); if (currentSpeedSetting.IsNull() || speedSetting != currentSpeedSetting.Value()) {