C++ Manipulator fixedC++ manipulator fixed function is used to set the floatfield format flag for the str stream to fixed. When we set floatfield to fixed, then floating point values are written using fixed notation; the value is represented with exactly as many digits in the decimal part as specified by the precision filed (precision) and with no exponent part. C++98 The floatfield format flag is a selective and a toggle flag: it can take one, both or none of the following values as given below -
C++11 The floatfield format flag is a selective and a toggle flag: It can take any of the following values, or none as given below-
SyntaxParameterstr: stream object whose format flag is affected. Return valueIt returns argument str. Data RacesData races may cause when modifies str concurrent access to the same stream object. Exceptionsstr is in a valid state, if an exception is thrown. Example 1Let's see the simple example to demonstrate the use of fixed manipulator: Output: The number 0.01 in fixed: 0.010000 The number 0.01 in scientific: 1.000000e-02 The number 0.01 in hexfloat: 0x1.47ae147ae147bp-7 The number 0.01 in default: 0.01 Parsing 0x1P-1022 as hex gives 0 Example 2Let's see another simple example: Output: default: 3.1416 2006 1e-10 fixed: 3.14159 2006.00000 0.00000 scientific: 3.14159e+00 2.00600e+03 1.00000e-10 Example 3Let's see another simple example: Output: The number 0.01 in fixed: 0.010000 The number 0.01 in scientific: 1.000000e-02 The number 0.01 in hexfloat: 0x1.47ae147ae147bp-7 The number 0.01 in default: 0.01 Parsing 0x1P-1022 as hex gives 0
Next TopicC++ Manipulator
|