std::fixed














































std::fixed



          

std::fixed - Fixed Floating-point notation : It write floating-point values in 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.
   
   Defined in header <ios>
   std::ios_base& fixed( std::ios_base& str );

For Example:
//c++ program
//std::fixed
#include<iostream>  
using namespace std
int main(){ 
    // Initializing floating point variable 
    double a=4.223234232
    double b=722.0
  
    // Specifying precision 
    cout.precision(4); 
      
    // Printing normal values 
    cout<<"Normal values : a="<<a<<" "<<"b="<<b<<endl
      
    // Printing values using fixed ( till 4 ) 
    cout<<"Values using fixed"<< std::fixed<<endl;; 
    cout<<"a="<<a<<" "<<"b="<<b<<endl;  

    return 0
   
  Output:
   Normal values : a=4.223 b=722
   Values using fixed
   a=4.2232 b=722.0000



More Articles of More Rakesh:

Name Views Likes
std::dec 456 1
std::clog 723 1
std::scanf 539 0
std::fixed 3370 0
std::freopen 532 0
std::fclose 287 1
std::cerr and std::wcerr 764 0
Std:cout 400 1
std::fprintf() 580 0
std::setw and std::setfill 1148 0
std::defaultfloat 602 0
std::endl 245 0
std::cin 293 1
std::fread() 645 0
std::fopen() 615 1

Comments