Project

General

Profile

Actions

Bug #860

closed

Incorrect conversion of numeric_limits<double>::max by OFStandard::ftoa()

Added by Marco Eichelberg almost 7 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Category:
Library
Target version:
-
Start date:
2018-11-30
Due date:
% Done:

100%

Estimated time:
30:00 h
Module:
ofstd
Operating System:
Compiler:

Description

While writing some unit tests, I've observed a potential issue with ofstd::ftoa(). When reading a value from a tag of VR: FD to OFstring, the value represented by the string is incorrect, if the value of the tag is the upper boundary of double (std::numeric_limits<double>::max). While the value in the tag is 1.7976931348623157e+308, the value of the string is 1.7976931348623167e+308. Now the string cannot be converted to double (e.g. using std::stod), because it exceeds the representable maximum of double. The conversion seems to be correct when using sprintf instead of ftoa.

Reported by DCMTK forum user "FKupsch": https://forum.dcmtk.org/viewtopic.php?f=1&t=4806

Actions

Also available in: Atom PDF