Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include <cmath>
- using namespace std;
- #define PRECISION 1e-4
- double _exp(const double x)
- {
- double dVal, dTemp;
- int nStep = 1;
- for (dVal = 1.0, dTemp = 1.0; fabs(dTemp) >= PRECISION; ++nStep)
- {
- dTemp *= x / nStep;
- dVal += dTemp;
- }
- return dVal;
- }
- int main(int argc, char** argv) {
- double x = -1;
- cout << _exp(x) << endl << exp(x) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement