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

Thrift compiler (C/C++) truncates small doubles to a fixed number of digits after the decimal point

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 0.15.0
    • None
    • C++ - Compiler
    • None

    Description

      When the Thrift C++ compiler generates double constants in .h files, it
          (1) doesn't use scientific notation (e.g., 123.45e-22)
          (2) uses a fixed number of digits after the decimal point

      Hence, if the constant to be generated is small but non-zero, it shows up as "0.0000000000000000" (17 digits of precision, 16 after the decimal point).

      (1) Would somebody please explain why scientific notation is not used when appropriate?

      (2) Assuming that there is a good reason for not using scientific notation, I have created a fix that instead generates "0.000000000000000000012345000000000000" (17 digits of precision following the 19 '0's between the decimal point and the '1'. 

      I made this fix in .../generate/t_erl_generator.cc,, .../generate/t_generator.cc,, and .../test/DoubleConstantsTest.thrift. 

      I will submit a github pull request shortly.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rgumpertz Richard H. Gumpertz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0h
                  0h
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m