Skip to content

Round debug float output to 4 decimal places#55879

Closed
NickGerleman wants to merge 1 commit intofacebook:mainfrom
NickGerleman:export-D95041966
Closed

Round debug float output to 4 decimal places#55879
NickGerleman wants to merge 1 commit intofacebook:mainfrom
NickGerleman:export-D95041966

Conversation

@NickGerleman
Copy link
Contributor

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

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 3, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 3, 2026

@NickGerleman has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95041966.

NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
Summary:
Pull Request resolved: facebook#55879

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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 NickGerleman force-pushed the export-D95041966 branch 2 times, most recently from c863c2f to 7ade935 Compare March 6, 2026 02:54
NickGerleman added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
Summary:
Pull Request resolved: facebook#55879

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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
Summary:
Pull Request resolved: facebook#55879

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
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 added a commit to NickGerleman/react-native that referenced this pull request Mar 6, 2026
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
@meta-codesync meta-codesync bot closed this in 3483dfa Mar 6, 2026
@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @NickGerleman in 3483dfa

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Mar 6, 2026
@meta-codesync
Copy link

meta-codesync bot commented Mar 6, 2026

This pull request has been merged in 3483dfa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants