Skip to content

Format floats with the shortest round-trip digits - #23

Merged
dcj merged 1 commit into
mainfrom
fix/float-shortest
Oct 10, 2026
Merged

dcj merged 1 commit into
mainfrom
fix/float-shortest

Conversation

@dcj

@dcj dcj commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

`Property::setValue(float)` published `%f` text, so 21.4 went on the wire as `21.400000`. It now publishes the shortest decimal that reads back as the same float, in python-sdk's layout (`_format_float`: `repr()` without the exponent `+`): `21.4`, `40.0`, `1e-05`, `1e16`.

  • `homie_format_float()` and `homie_format_double()` in `ebus/homie/homie_datatype.h`; esp32-sdk's `NodeProperty::set(float|double)` will use them after this release.
  • Checked against Python on 199,212 random float32 values and 200,007 random doubles: no mismatches.
  • New Unity cases in `test_homie_datatype`; two expectations in `test_link_engine` and `test_settable_dispatch` move from `%f` text.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vz59zZzRfxFkWjW16egZoy

Property::setValue(float) published %f text (21.400000). It now publishes
the shortest decimal that reads back as the same float, laid out like
python-sdk's float text: 21.4, 40.0, 1e-05, 1e16. homie_format_float()
and homie_format_double() in homie_datatype.h do the formatting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vz59zZzRfxFkWjW16egZoy
@dcj
dcj merged commit 6546b60 into main Oct 10, 2026
8 checks passed
@dcj
dcj deleted the fix/float-shortest branch October 10, 2026 19:26
@dcj dcj mentioned this pull request Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant