Why this code give me 2 different result on ris1 and ris2?
Why they are not equivalent???
#include <iostream>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
using namespace std;
int main() {
double x1 = 0.4628471891711442;
double h = 0.51152525298500628;
double lambda = 0.99999999999999989;
double t = 0.10000000000000001;
double ris1 = 0;
double ris2 = 0;
ris1 = x1 - (h * exp(-lambda * t));
double sub = h * exp(-lambda * t);
ris2 = x1 - sub;
printf("\n\nris1 = %1.4e", ris1);
printf("\n\nris2 = %1.4e", ris2);
return 0;
}
Result:
ris1 = 8.9257e-017
ris2 = 1.1102e-016
I am working with mingw in eclipse. Here my mingw installed framework: http://ctrlv.in/638751