Mercurial > hg > orthanc
changeset 3312:b88937ef597b
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 26 Feb 2019 16:42:21 +0100 |
parents | f2f8aa6f78aa |
children | 3e0ad879eba2 |
files | Core/DicomParsing/DicomWebJsonVisitor.cpp |
diffstat | 1 files changed, 16 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomParsing/DicomWebJsonVisitor.cpp Tue Feb 26 13:10:40 2019 +0100 +++ b/Core/DicomParsing/DicomWebJsonVisitor.cpp Tue Feb 26 16:42:21 2019 +0100 @@ -324,16 +324,25 @@ Json::Value DicomWebJsonVisitor::FormatDouble(double value) { - long long a = boost::math::llround<double>(value); + try + { + long long a = boost::math::llround<double>(value); - double d = fabs(value - static_cast<double>(a)); + double d = fabs(value - static_cast<double>(a)); - if (d <= std::numeric_limits<double>::epsilon() * 100.0) + if (d <= std::numeric_limits<double>::epsilon() * 100.0) + { + return FormatInteger(a); + } + else + { + return Json::Value(value); + } + } + catch (boost::math::rounding_error&) { - return FormatInteger(a); - } - else - { + // Can occur if "long long" is too small to receive this value + // (e.g. infinity) return Json::Value(value); } }