Skip to content

Exploit the maximum float32/float64 precision in exported txt formats#34

Merged
jlblancoc merged 1 commit intodevelopfrom
feat/mm2txt-mm2ply-more-precision
Jan 29, 2026
Merged

Exploit the maximum float32/float64 precision in exported txt formats#34
jlblancoc merged 1 commit intodevelopfrom
feat/mm2txt-mm2ply-more-precision

Conversation

@jlblancoc
Copy link
Copy Markdown
Member

@jlblancoc jlblancoc commented Jan 29, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Corrected numeric formatting precision in PLY file exports with type-specific decimal and scientific notation
    • Updated TXT file exports with consistent formatting: 8 decimal places for coordinates and scientific notation for floating-point values

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 29, 2026

📝 Walkthrough

Walkthrough

This PR enhances numeric export formatting across two point cloud conversion tools. The mm2ply exporter introduces format-aware ASCII output by passing explicit format strings to a modified write_val lambda, while mm2txt applies consistent precision rules for coordinate and floating-point field output.

Changes

Cohort / File(s) Summary
PLY Exporter Formatting
apps/mm2ply/main.cpp
Updated write_val lambda to accept a format string parameter and apply mrpt::format() for ASCII mode. All write calls now supply field-type-specific formats: FLOAT/DOUBLE use scientific notation, UINT types use integer/unsigned formats.
TXT Exporter Formatting
apps/mm2txt/main.cpp
Applied consistent numeric precision: coordinates printed with 8 decimal places (%.8f), floating-point fields in scientific notation with 8 decimals (%.8e), and double fields with 16 significant digits (%.16le).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 ✨
Numbers dance in pristine rows,
Eight decimals—or sixteen—who knows?
Scientific notation flows so bright,
Your exports now formatted just right!
📊🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: improving precision in exported text formats by using maximum float32/float64 precision with format strings.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/mm2txt/main.cpp (1)

141-168: Fixed-point coord formatting can drop small values.

With %.8f on x/y/z (Line 144/148/152), values below ~1e-8 round to 0, which undermines the “max precision” goal and diverges from the %.8e used for other float fields. Consider using a scientific format (or %g) for coordinates too.

💡 Suggested change (use scientific format for coords)
-                mrpt::system::os::fprintf(f, "%.8f", xs.at(i));
+                mrpt::system::os::fprintf(f, "%.8e", xs.at(i));
...
-                mrpt::system::os::fprintf(f, "%.8f", ys.at(i));
+                mrpt::system::os::fprintf(f, "%.8e", ys.at(i));
...
-                mrpt::system::os::fprintf(f, "%.8f", zs.at(i));
+                mrpt::system::os::fprintf(f, "%.8e", zs.at(i));

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.03%. Comparing base (cebc610) to head (c6e1670).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop      #34   +/-   ##
========================================
  Coverage    77.03%   77.03%           
========================================
  Files          179      179           
  Lines         9526     9526           
  Branches       917      917           
========================================
  Hits          7338     7338           
  Misses        2188     2188           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlblancoc jlblancoc merged commit 0d52dbf into develop Jan 29, 2026
15 checks passed
@jlblancoc jlblancoc deleted the feat/mm2txt-mm2ply-more-precision branch January 29, 2026 09:36
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