Possible Duplicate:
Precision of Floating Point
I am trying to calculate the probability using some floating point numbers but always my final result is coming out as zero. Please find the below code and examples.
sd_attr4_ok = 3022.115234
unknwn_attr4 = 111
mean_attr4_ok = 32824.566406
var_attr4_ok = 9133180.000000
(1/(sqrt(2*3.14)*sd_attr4_ok))*(1/pow(2.71828,((pow((atoi(unknwn_attr4)-mean_attr4_ok),2))/(2*var_attr4_ok))))
Please kindly help me in resolving this issue.
If I run the program below, I still get 0.000000:
#include <stdio.h>
#include <math.h>
int main()
{
float a=(1/(sqrt(2*3.14)*3022.115234))*(1/pow(2.71828,(pow((111-32824.5666406),2))/(2*9133180)));
printf("The probability is - %f\n",a);
return 0;
}
And similarly, if I run the program below I still get 0.000000.
#include <stdio.h>
#include <math.h>
int main()
{
float a=(1/(sqrt(2*3.14)*3022.115234));
float b=pow((111-32824.5666406),2)/(2*9133180);
float c=pow(2.71828,b);
float d=1/c;
printf("The probability is %f-%f-%f-%f\n",a,b,c,d);
return 0;
}
My result-set:
***OK*** 0.908396-0.000084-0.000168-0.000000-0.000000
***FRAUD*** 0.091604-0.000835-0.000835-0.000000-0.000000
***OK FRAUD*** 0.000000 0.000000
If you see the above results the 4th and 5th attribute results is coming through the above program.And the third line represents the product of all the 5 values coming from OK and FRAUD. But my final results are coming out zero and not able to compare the values.