Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"1 + QDecDouble" causes an odd result without warnings #7

Open
GoogleCodeExporter opened this issue Nov 19, 2015 · 3 comments
Open

Comments

@GoogleCodeExporter
Copy link

> What steps will reproduce the problem?

I compiled
      QDecDouble num("0.1");
      QDecDouble aux = 1 + num;
      cout << aux << endl;
and the result was
        8.19999E-393
which is very close to zero, which is not adequate. 

However, I compiled 
        double num(0.1);
        double aux = 1 + num;
        cout << aux << endl;
and the result was 
        1.1
which is correct. I obtained the same result using "qreal" instead of "double", 
of course.

> What version of the product are you using? On what operating system?
QDecimal 1.0.1. Kubuntu 13.04.

Thanks for QDecimal! 

Original issue reported on code.google.com by b3811...@uggsrock.com on 10 Aug 2013 at 5:48

@GoogleCodeExporter
Copy link
Author

I also executed, with Gcc 4.7.3:

    #include <decimal/decimal>
    // [...]        

    typedef std::decimal::decimal64 dec64; 

    dec64 num(0.1dd);
    dec64 aux = 1 + num;

    dec64 onePointOne(1.1dd);
    if (aux == onePointOne)
        std::cout << "1.1" << std::endl;
    else
        std::cout << "ERROR." << std::endl;

and the result was 
    1.1
which is correct. 

Original comment by b3811...@uggsrock.com on 11 Aug 2013 at 4:49

@GoogleCodeExporter
Copy link
Author

If it can be useful to anyone, I created a simple example that I attach. When 
GCC 4.7.3 tries to compile it, instead of generating an unintended code, GCC 
talks about an error ("no match for call to 'operator+’") and it does not 
continue compiling.

Original comment by b3811...@uggsrock.com on 12 Aug 2013 at 10:44

Attachments:

@GoogleCodeExporter
Copy link
Author

If it can be useful to anyone, I created another simple example, that I attach. 
GCC 4.7.3 compiles it, and the intended result is seen:
    1.1
    1.1

Original comment by b3811...@uggsrock.com on 13 Aug 2013 at 12:16

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant