| Summary: | G4UIcommand.cc double to string rounds to typically 7 digits | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Helmut.Burkhardt |
| Component: | intercoms | Assignee: | asai |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | niess, wdconinc |
| Priority: | P4 | ||
| Version: | 10.2 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | Modified G4UIcommand.cc using std::setprecision(17) for double to string | ||
Thank you for reporting the issue. We will fix it very soon, but the fix won't go with version 10.3 scheduled on this coming Friday. It will go with the next patch release, and we will also make a retroactive patch for 10.2. Kind regards, Makoto Asai The fix is included in the coming patch. Please note that this double precision printout is implemented as an option, and you need to issue a UI command "/control/useDoublePrecision". Thanks for reporting this issue. Makoto *** Problem 2070 has been marked as a duplicate of this problem. *** *** Problem 2155 has been marked as a duplicate of this problem. *** |
Created attachment 430 [details] Modified G4UIcommand.cc using std::setprecision(17) for double to string Background applications on large accelerators require high accuracy in geometry, like micrometers in kilometres or over 9 significant digits. I was surprised to see that gun positions and energies are reduced to typically 7 digits. Traced to G4UIcommand.cc os << doubleValue; using default precision or less than float. Seen in 4 places in G4UIcommand.cc G4String G4UIcommand::ConvertToString(G4double doubleValue) G4String G4UIcommand::ConvertToString(G4double doubleValue,const char* unitName) G4String G4UIcommand::ConvertToString(G4ThreeVector vec) G4String G4UIcommand::ConvertToString(G4ThreeVector vec,const char* unitName) Proposed fix is to replace "os << “ by "os << std::setprecision(17) <<“ to avoid any loss in double precision. Worked for me to get precise gun values - modified file attached. Maybe be good to check also in other places where ostringstream is used. Best regards, Helmut