Conversation
fe99d38 to
c99143e
Compare
libsrc/Helper.cpp
Outdated
| ostringstream sstream; | ||
| sstream << scientific << f; | ||
| return sstream.str(); | ||
| sstream << fixed << setprecision(15) << f; |
There was a problem hiding this comment.
sstream.imbue(std::locale::classic());
before using the sstream.
libsrc/Helper.cpp
Outdated
| return sstream.str(); | ||
| sstream << fixed << setprecision(15) << f; | ||
| string formatted_f = sstream.str(); | ||
| size_t dot_position = formatted_f.find('.'); |
There was a problem hiding this comment.
You can move thin into the if statement as it is only used in that scope.
Use fixed notation precision 15 in place of scientific notation default precision resolves QIICR#414
8cb33bd to
6247fa3
Compare
libsrc/Helper.cpp
Outdated
| ostringstream sstream; | ||
| sstream << scientific << f; | ||
| return sstream.str(); | ||
| sstream << fixed << setprecision(15) << f; |
There was a problem hiding this comment.
If you use fixed, you should only use a precision of e.g. 9.
Reason using fixed percision only specifies the numbers after(!) the decimal point.
So currently you always produce to long strings.
9 digits after the decimal points would be enough in medical imageing cases are enough in my opinion and it is highly unlikely that you need more then 6 digits infront.
4cf93f2 to
393d72f
Compare
|
Here's my shot: http://cpp.sh/72ipr To squeeze every little possible bit of precision out of it, you could print both scientific and fixed notation to strings and compare their lengths. If the scientific notation fits, use it. Fixed notation otherwise. The numeric_limits::max_digits10 ensures that both notations represent the maximum possible precision. |
|
Nevermind, I just noticed that DCMQI only used float so it makes things easier in the context of 16 characters. The standard library provides useful constants for serializing floating point numbers with maximum precision and for float (with all the extras) it always fits even into less than 16 characters. I will create a pull request for review. |
|
replaced by #416 |
resolves #414