CNA-BUG-073: Math ToString methods print floats with six significant digits and the C++ global locale, where XNA 4.0 uses Single.ToString(CurrentCulture)

CNA snapshot 009d40f5  ·  Known Issues › Current bugs  ·  source links pinned to 009d40f5

✓

Evidence basis: source-verified at the pinned commit; inferred from the source (the behaviour was not run); tests exist (not executed for this page). Claims on this page were checked by reading the CNA source at commit 009d40f5; unless a sentence says otherwise, nothing here was built or executed. Nothing on this page was executed unless the Evidence section says so.

The math ToString methods stream floats through a default std::ostringstream (6 digits, global locale), while .NET's Single.ToString prints up to 7 significant digits in the current culture.

Identifier
CNA-BUG-073
Category
Bug
Subsystem
Math & geometry
Status
Open
Verified against
CNA 009d40f5 (009d40f5dd085c4e674d3479675fac84b12b3e0a)
Severity
Low (a triage suggestion, not a project priority)
Evidence basis
Inferred (strong): follows from the code, but the behaviour was not run
Tests touching this area
Yes: see Current tests
Affected contract
Microsoft::Xna::Framework::Vector2/Vector3/Vector4/Quaternion/Matrix/Plane::ToString()

Expected behaviour

XNA 4.0 formats each component with Single.ToString(CultureInfo.CurrentCulture), which in the .NET Framework prints up to seven significant digits (general format) and the culture's decimal separator.

Actual behaviour at TARGET

Vector3::ToString in Vector3.cpp (and its siblings) streams the raw floats into a default-constructed std::ostringstream: six significant digits and the C++ global locale. 1.2345678f prints as 1.23457 (XNA: 1.234568). Only Matrix's outer brace format has been measured against XNA (its comment cites XNASWEEP-183).

Source locations

Evidence

Checked by reading the named sources at 009d40f5; nothing was built or executed for this entry. The digit-count difference follows from the two formatting rules; culture handling depends on the C++ global locale the application sets.

Focused reproduction

No focused reproduction is known. Nothing has been invented here; the evidence above is what exists.

Current tests

Math tests check ToString with short values only (for example whole numbers).

Regression test

A test that formats 1.2345678f and 0.1f in each type and compares with the .NET Framework general-format output, and one under a comma-decimal culture.

Blast radius

Logs and UI text built from math ToString; parsers that expect XNA's strings.

Workaround

Format components yourself where the text matters.

The same subject is explained at several altitudes. These are the neighbouring pages at each one.

Known issues
Bug index