Cout long double issue

前端 未结 4 1617
一向
一向 2021-01-14 06:01

So, I\'m working on a C++ project. I have a var of long double type and assigned it a value like \"1.02\"

Then, I try to use cout to print it and the result is: -0

4条回答
  •  悲哀的现实
    2021-01-14 06:37

    It seems to be a problem with compiler. Take a look here: http://mingw.5.n7.nabble.com/Strange-behaviour-of-gcc-4-8-1-with-long-double-td32949.html

    Use printf or convert a value of your variable to double before passing to cout. (BTW are sure you need 80-bit precision?)

提交回复
热议问题