J. Nick Koston a1cc7ea861 [api] Use integer comparison for float zero checks in protobuf encoding
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.
2026-04-06 13:01:19 -10:00
2023-06-12 17:00:34 +12:00
2022-09-06 15:48:01 +12:00
2025-12-21 09:26:03 -05:00
2024-03-28 10:20:51 +13:00
2025-07-17 22:40:28 +12:00
2025-12-08 14:37:45 -05:00
2026-03-12 07:34:53 +13:00
2025-07-17 22:40:28 +12:00
S
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%