mirror of
https://github.com/esphome/esphome.git
synced 2026-07-11 01:15:33 +00:00
a1cc7ea8612d7338db17d27fea192de1948df525
encode_float() already used union type-punning to convert a float to its raw uint32_t bits for encoding. However, its zero check still used a floating-point comparison (value == 0.0f), and calc_float() used value != 0.0f with no type-punning at all. Extract the existing union type-punning into a shared float_to_raw() helper and use it in both places, so the zero check is a simple integer comparison (raw == 0) in both encode_float() and calc_float(). This ensures size calculation always matches encoding. On platforms without hardware FPU (ESP8266, some LibreTiny chips), value != 0.0f compiles to a software float library call (__nesf2 or similar). The new code does a single integer comparison instead.
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme
Multiple Licenses
549 MiB
Languages
C++
60.1%
Python
39.3%
C
0.3%
JavaScript
0.2%
