# HG changeset patch # User Sebastien Jodogne # Date 1551195741 -3600 # Node ID b88937ef597b33c4387a546c751827019bcdc205 # Parent f2f8aa6f78aac5392538f2e6968f78bee2b500ce fix diff -r f2f8aa6f78aa -r b88937ef597b Core/DicomParsing/DicomWebJsonVisitor.cpp --- 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(value); + try + { + long long a = boost::math::llround(value); - double d = fabs(value - static_cast(a)); + double d = fabs(value - static_cast(a)); - if (d <= std::numeric_limits::epsilon() * 100.0) + if (d <= std::numeric_limits::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); } }