Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::exp

 

std::exp is am STL math function to obtain the natural logarithm of a value.

 

#include <cmath>
#include <iostream>

int main()
{
  //Set output to fixed length
  std::cout << std::fixed;
  for (double x = 0.0; x < 1.0; x+=0.1)
  {
    const double y = std::exp(x);
    std::cout
      << "std::exp(" << x << ") = "
      << y << '\n';
  }
}

 

Screen output:

 

std::exp(0.000000) = 1.000000
std::exp(0.100000) = 1.105171
std::exp(0.200000) = 1.221403
std::exp(0.300000) = 1.349859
std::exp(0.400000) = 1.491825
std::exp(0.500000) = 1.648721
std::exp(0.600000) = 1.822119
std::exp(0.700000) = 2.013753
std::exp(0.800000) = 2.225541
std::exp(0.900000) = 2.459603
std::exp(1.000000) = 2.718282

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict