Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Higher precision for the result log(x)
Forum Updated to NodeBB v4.3 + New Features

Higher precision for the result log(x)

Scheduled Pinned Locked Moved C++ Gurus
4 Posts 3 Posters 1.4k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    newe12
    wrote on last edited by newe12
    #1

    Hi!

    I am using

    double c, y, z;
    double x = c*(log(y)-log(z));
    

    Well the result is correct, as long as "c" is small. If it gets bigger, the result of x diverges pretty much from the same result calculated in R or in Mathematica.

    I suppose, a higher precision of more decimal places - especially if y and/or z is small - might lead to better results.

    I tried to solve it with QString and precision, but this did not work so far.

    Is there a better solution for increasing the precision of decimal places?

    Please let me know!

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      This is not really a Qt question.

      C++ double type has a precision defined by the IEEEE 754 standard and it is not configurable.

      If you need higher precission than it offers you need to use another (custom) type.
      There are 3rd party libraries providing such types, for example GMP, ttmath or the Boost Multiprecision Library.

      1 Reply Last reply
      1
      • N Offline
        N Offline
        newe12
        wrote on last edited by
        #3

        Thanks!

        I will have a look!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Topic moved to C++ Gurus

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved