From ec79e091bc030b0e0f3ac22cc594a46d8126a2b1 Mon Sep 17 00:00:00 2001 From: ahmedbilal9 Date: Tue, 11 Nov 2025 13:41:11 +0500 Subject: [PATCH] [Geom] Fix setting precision for matrix values in TGDMLWrite::CreateMatrixN (#20345) Fixes #20342 Apply fFltPrecision setting to matrix value exports instead of using default C++ ostream precision (6 digits). Authored-by: Ahmed Bilal --- geom/gdml/src/TGDMLWrite.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geom/gdml/src/TGDMLWrite.cxx b/geom/gdml/src/TGDMLWrite.cxx index 56485c1263916..08915d5ed80ba 100644 --- a/geom/gdml/src/TGDMLWrite.cxx +++ b/geom/gdml/src/TGDMLWrite.cxx @@ -164,7 +164,6 @@ See that function for details. #include #include - TGDMLWrite *TGDMLWrite::fgGDMLWrite = nullptr; namespace { @@ -2040,9 +2039,10 @@ XMLNodePointer_t TGDMLWrite::CreateMatrixN(TGDMLMatrix const *matrix) XMLNodePointer_t mainN = fGdmlE->NewChild(nullptr, nullptr, "matrix", nullptr); fGdmlE->NewAttr(mainN, nullptr, "name", matrix->GetName()); fGdmlE->NewAttr(mainN, nullptr, "coldim", TString::Format("%zu", cols)); + const TString fltPrecision = TString::Format("%%.%dg", fFltPrecision); for (size_t i = 0; i < rows; ++i) { for (size_t j = 0; j < cols; ++j) { - vals << matrix->Get(i, j); + vals << TString::Format(fltPrecision.Data(), matrix->Get(i, j)); if (j < cols - 1) vals << ' '; }