Display a number decimal format instead as an exponential in cout

前端 未结 2 1044
我在风中等你
我在风中等你 2021-01-27 12:33

I calculated a total of floats and I got a number like 509990e-405. I\'m assuming this is the short version; how can I cout this as a full number?

2条回答
  •  Happy的楠姐
    2021-01-27 13:24

    You can force the output to be not in scientific notation, and to have the sufficient precision to show your small number.

    #include 
    
    // ...
    
    long double d = 509990e-405L;
    std::cout << std::fixed << std::setprecision(410) << d << std::endl;
    

    Output:

    0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050999000000

    If you really want this is another question.

提交回复
热议问题