What is the role of **std::setprecision()** without **std::fixed** in c++?

前端 未结 4 985
陌清茗
陌清茗 2021-02-04 15:52

As shown in the tutorial http://www.cplusplus.com/reference/iomanip/setprecision/

// setprecision example
#include      // std::cout, std::fixed
         


        
4条回答
  •  失恋的感觉
    2021-02-04 16:04

    This is because "When floatfield is set to fixed, floating-point values are written using fixed-point notation: the value is represented with exactly as many digits in the decimal part as specified by the precision field (precision) and with no exponent part." ref. http://www.cplusplus.com/reference/ios/fixed/

提交回复
热议问题