Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3636

Double precision is not fully preserved in C++ TJSONProtocol

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.3
    • 0.10.0
    • C++ - Library
    • None
    • Linux Mac Windows

    Description

      The precision is 15 bits after dot of format casting from double to string in Thrift-cpp-library- json-protocol.
      But the expected precision is 16 bits after dot in Thrift-json-protocol.

      The solution:
      To Change code 'str.precision(std::numeric_limits<double>::digits10 + 1);' to 'str.precision(std::numeric_limits<double>::digits10 + 2);'
      in function doubeToString file TJSONProtocol.cpp at line 524,
      e.g:
      before:
      In C++ TJsonProtocol.cpp:
      double a = 1.12345678906666663;
      string astr = doubleToString(a);
      double b = stringToDouble(astr);
      the result as below:
      a = 1.1234567890666667
      astr = "1.123456789066667"
      b = 1.1234567890666669
      after changing:
      the result as below:
      a = 1.1234567890666667
      astr = "1.1234567890666667"
      b = 1.1234567890666667
      This result is expected.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            gityf WangYaofu
            gityf WangYaofu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment