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

后端 未结 4 847
耶瑟儿~
耶瑟儿~ 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:05

    If you read 2.13.3/1 you'll see:

    The type of a floating literal is double unless explicitly specified by a suffix. The suffixes f and F specify float, the suffixes l and L specify long double.

    In other words there is no suffix to specify double for a literal floating point constant if you change the default to float. Unfortunately you can't have the best of both worlds in this case.

提交回复
热议问题