What is the precision of long double in C++?

后端 未结 2 1082
深忆病人
深忆病人 2020-11-29 06:40

Does anyone know how to find out the precision of long double on a specific platform? I appear to be losing precision after 17 decimal digits, which is the sa

2条回答
  •  臣服心动
    2020-11-29 07:02

    You can find out with std::numeric_limits:

    #include      // std::cout
    #include        // std::numeric_limits
    int main(){
        std::cout << std::numeric_limits::digits10 << std::endl;
    }
    

提交回复
热议问题