Commit 62952dd
ENH: Use NumberToString for lossless float metadata in MetaImage IO
Non-template MetaData fields of type double, float, vector<double>, and
Matrix<double> were serialized via std::ostringstream with default 6-digit
precision, silently truncating values with more than 6 significant digits.
Replace the lossy stream insertions with itk::ConvertNumberToString(),
which wraps Google double-conversion::ToShortest() and produces the
shortest decimal string that round-trips exactly through strtod/strtof.
Three call sites are affected:
- ExposeMetaData<double> / ExposeMetaData<float> in WriteImageInformation()
- ExposeMetaData<std::vector<double>> (manual loop replacing joinElements)
- WriteMatrixInMetaData<N>() template in the header
See: #3249
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 61cc38d commit 62952dd
2 files changed
Lines changed: 13 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
220 | 221 | | |
221 | 222 | | |
222 | 223 | | |
223 | | - | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
458 | 459 | | |
459 | 460 | | |
460 | 461 | | |
461 | | - | |
| 462 | + | |
462 | 463 | | |
463 | 464 | | |
464 | 465 | | |
465 | | - | |
| 466 | + | |
466 | 467 | | |
467 | 468 | | |
468 | 469 | | |
| |||
510 | 511 | | |
511 | 512 | | |
512 | 513 | | |
513 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
514 | 522 | | |
515 | 523 | | |
516 | 524 | | |
| |||
0 commit comments