[#31] Add --hexfloat option to dump bit-exact float representations#114
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a --hexfloat/-x option to the dump command to annotate float/double values with their IEEE-754 bit-exact hexadecimal representation (matching Unity’s binary2text -hexfloat style), improving diffability of dumps.
Changes:
- Introduces a
HexFloatflag inTextDumperTooland applies it to scalarfloat/doublevalues and basic-type array elements. - Exposes
-x/--hexfloaton the CLIdumpcommand and wires it through to the dumper options. - Adds targeted tests asserting known float/double bit patterns, plus documentation updates for the new option.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| UnityDataTool/Program.cs | Adds and wires the -x/--hexfloat CLI option into TextDumperTool.DumpOptions. |
| UnityDataTool.Tests/DumpTests.cs | Adds a test verifying --hexfloat output includes expected IEEE-754 hex patterns. |
| TextDumper/TextDumperTool.cs | Implements float/double formatting helpers and applies them to scalar reads + basic-type array dumps. |
| Documentation/command-dump.md | Documents the new option and shows an example of the annotated output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
SkowronskiAndrew
marked this pull request as ready for review
July 24, 2026 20:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #31.
Tiny differences between float values get lost when they are converted to decimal, which makes them invisible when diffing two dumps. This adds the equivalent of binary2text's
-hexfloatoption: with-x/--hexfloat, every float and double value is followed by its bit-exact hexadecimal representation, in the samevalue(0xhex)format binary2text uses:Note that binary2text only annotates 32-bit floats (
doubleis a missing case in its output macro table); this implementation covers both float and double.Changes
TextDumperTool: newHexFloatoption, applied inReadValue(scalars — which also covers compound types likeVector3f/ColorRGBA, whose components are float leaf nodes) and to basic-type array elements. Default output is unchanged, so the expected-data snapshots are untouched.-x/--hexfloatoption on the dump command.SerializationDemobundle with-x/--hexfloatand assert the known IEEE 754 bit patterns of its float and double fields (verified independently against python'sstruct.pack).command-dump.md.Testing
dotnet test -c Release— full suite green (775 passed, 10 skipped, 0 failed).Manually verified scalar fields,
ColorRGBAcomponents, and float array elements on the checked-in test data, and that default output is byte-identical to before.