2

I have a problem using cout and __float128.

Code is:

__float128 su1 = 0.33333333333333333q;         
cout << "1 / 3 = " << su1 << endl;

And error from g++ (GCC) 9.3.0 is:

g++ -std=gnu++17 -Wall -g -c -o third.o third.cc
third.cc: In function ‘int main()’:
third.cc:41:55: error: ambiguous overload for ‘operator<<’ (operand types are ‘std::basic_ostream<char>’ and ‘__float128’)
   41 |     cout << "1 / 3 = " << su1 << endl;
      |     ~~~~~~~~~~~~~~~~~~ ^~ ~~~~~
      |           |            |
      |           |             __float128
      |           std::basic_ostream<char>
In file included from /lib/gcc/x86_64-pc-cygwin/9.3.0/include/c++/iostream:39,
                 from third.cc:9:

Any ideas about the error?

0 Answers0