Round debug float output to 4 decimal places#55879
Open
NickGerleman wants to merge 1 commit intofacebook:mainfrom
Open
Round debug float output to 4 decimal places#55879NickGerleman wants to merge 1 commit intofacebook:mainfrom
NickGerleman wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary:
Float values in debug layout metrics output (used by Fantom test assertions) are
subject to floating-point precision differences across platforms and compilers
(e.g., `66.6667` vs `66.66666412353516`), causing flaky test comparisons.
This changes `toString(const double&)` in `DebugStringConvertible.cpp` to format
floats with 4 decimal places using `snprintf("%.4f")` and strip trailing zeros,
replacing `double-conversion`'s `ToShortest()`. This is debug-only code (guarded
by `#if RN_DEBUG_STRING_CONVERTIBLE`) so the precision change is safe for all
consumers.
The `double-conversion` dependency is also removed from the BUCK file since it is
no longer used.
Output examples:
- `0.0` → `"0"`
- `100.0` → `"100"`
- `66.66666412353516` → `"66.6667"`
- `1.5` → `"1.5"`
- `33.333333` → `"33.3333"`
Changelog: [Internal]
Reviewed By: javache
Differential Revision: D95041966
|
@NickGerleman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95041966. |
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:
Float values in debug layout metrics output (used by Fantom test assertions) are
subject to floating-point precision differences across platforms and compilers
(e.g.,
66.6667vs66.66666412353516), causing flaky test comparisons.This changes
toString(const double&)inDebugStringConvertible.cppto formatfloats with 4 decimal places using
snprintf("%.4f")and strip trailing zeros,replacing
double-conversion'sToShortest(). This is debug-only code (guardedby
#if RN_DEBUG_STRING_CONVERTIBLE) so the precision change is safe for allconsumers.
The
double-conversiondependency is also removed from the BUCK file since it isno longer used.
Output examples:
0.0→"0"100.0→"100"66.66666412353516→"66.6667"1.5→"1.5"33.333333→"33.3333"Changelog: [Internal]
Reviewed By: javache
Differential Revision: D95041966