(C++) std::scientific

February 24, 2017 · View on GitHub

 

 

 

 

 

(C++) std::scientific

 

std::scientific is a stream manipulator for real numbers to be displayed in the scientific notation.

 


#include <iostream> int main() {   const double x = 123.456;   std::cout            << x << '\n'     << std::fixed      << x << '\n'     << std::scientific << x << '\n'; }

 

Screen output:

 


123.456 123.456000 1.234560e+02

 

 

 

 

 

 

Contents

  1. 1int main() { const double x = 123.456; std::cout #include &#x3C;iostream> int main() { const double x = 123.456; std::cout &#x3C;&#x3C; x &#x3C;&#x3C; '\n' &#x3C;&#x3C; std::fixed &#x3C;&#x3C; x &#x3C;&#x3C; '\n' &#x3C;&#x3C; std::scientific &#x3C;&#x3C; x &#x3C;&#x3C; '\n'; }
  2. 2123.456 123.456000 1.234560e+02