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 d286207c3e8686..4a04028e910d68 100644 --- a/src/app/clusters/fan-control-server/fan-control-server.cpp +++ b/src/app/clusters/fan-control-server/fan-control-server.cpp @@ -346,9 +346,9 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt VerifyOrReturn(EMBER_ZCL_STATUS_SUCCESS == status, ChipLogError(Zcl, "Failed to get SpeedSetting with error: 0x%02x", status)); - float percent = percentSetting.Value(); - // Minus insignificant number 0.00000001 before ceil() to avoid floating point precision error - uint8_t speedSetting = static_cast(ceil(speedMax * (percent * 0.01) - 0.00000001)); + 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)); if (currentSpeedSetting.IsNull() || speedSetting != currentSpeedSetting.Value()) {