[Debian-med-packaging] Bug#1060677: Rounding error in OFStandard::atof

Mathieu Malaterre malat at debian.org
Fri Jan 12 14:55:40 GMT 2024


Source: dcmtk
Version: 3.6.7-8+b1

I believe I found an edge case in OFStandard::atof logic. Consider the
following ASCII string float > 16 bytes (valid case for input such as
XML or JSON).

Here is what I see on my side Debian/stable (dcmtk 3.6.7):

$ ./fd
0x1.ccccccccccccdp+3
0x1.cccccccccccccp+3

This has an impact when using DcmFloatingPointDouble::putString (VR:FD).

Thanks !

ref code is

% cat ../fd.cxx
#include "dcmtk/dcmdata/dcfilefo.h"

int main() {
  const uint8_t bytes[] = {0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x2C, 0x40};
  std::string result;
  result = "14.399999999999999";
  OFBool success;
  double d2 = OFStandard::atof(result.c_str(), &success);
  std::cout << std::hexfloat << d2 << std::endl;
  double d3 = std::stod(result);
  std::cout << std::hexfloat << d3 << std::endl;

  return 0;
}



More information about the Debian-med-packaging mailing list