File tree 1 file changed +3
-3
lines changed
src/app/clusters/fan-control-server
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -346,9 +346,9 @@ void MatterFanControlClusterServerAttributeChangedCallback(const app::ConcreteAt
346
346
VerifyOrReturn (EMBER_ZCL_STATUS_SUCCESS == status,
347
347
ChipLogError (Zcl, " Failed to get SpeedSetting with error: 0x%02x" , status));
348
348
349
- float percent = percentSetting.Value ();
350
- // Minus insignificant number 0.00000001 before ceil() to avoid floating point precision error
351
- uint8_t speedSetting = static_cast <uint8_t >(ceil (speedMax * ( percent * 0.01 ) - 0.00000001 ));
349
+ uint16_t percent = percentSetting.Value ();
350
+ // Plus 99 then devide by 100 instead of multiplying 0.01 to workaround floating point precision error
351
+ uint8_t speedSetting = static_cast <uint8_t >(ceil (( speedMax * percent + 99 ) / 100 ));
352
352
353
353
if (currentSpeedSetting.IsNull () || speedSetting != currentSpeedSetting.Value ())
354
354
{
You can’t perform that action at this time.
0 commit comments