Is there a floating point literal suffix in C++ to make a number double precision?

后端 未结 4 871
耶瑟儿~
耶瑟儿~ 2021-01-04 01:26

I\'m currently working on a C++ project which does numerical calculations. The vast, vast majority of the code uses single precision floating point values and works perfectl

4条回答
  •  春和景丽
    2021-01-04 02:01

    If you can afford GCC 4.7 or Clang 3.1, use a user-defined literal:

    double operator "" _d(long double v) { return v; }
    

    Usage:

    std::cout << sizeof(1.0E200_d) << std::endl;
    std::cout << 1.0E200_d << std::endl;
    

    Result:

    8
    1e+200
    

提交回复
热议问题