[GiNaC-list] Unwanted digits when performing arithmetic computations

Dr. Mithun Bairagi bairagirasulpur at gmail.com
Sat Oct 26 17:38:13 CEST 2024


Dear all ginac lovers, I have got some wrong results when performing some
simple computations using ginac.
I have compiled and run the following c++ program using ginac-1.8.7,
cln-1.3.7  (mingw64 compiler,  gcc version 14.2.0, windows 10 os),

#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main()
{
    cout<<(numeric(0.1)+numeric(7))<<endl;
    cout<<(numeric("0.01")*numeric("9"))<<endl;
    cout<<(numeric("0.01")*numeric("99"))<<endl;
}

the above program shows the following result:
7.1000000000000000056
0.089999999999999999996
0.98999999999999999995

I have got some unwanted digits which look very ugly. I think the result
should be
7.1
0.09
0.99


Best regards,
Mithun Bairagi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ginac.de/pipermail/ginac-list/attachments/20241026/2f304fff/attachment.htm>


More information about the GiNaC-list mailing list