Issue of Double Data type.Please kindly Help

 

Hi

I have some problem of the simple code listed below


double z;

double base=0.1;

y=Digits;

z=MathPow(base,y);  


When Digits = 5 , which means MathPow(0.1,5) , z becomes 0 , 

Below is what I output with different value of y, it only works up to y = 4, anyone can kindly suggest what is the issue?

y = 3 ; z = 0.001

y= 4 ;  z = 0.0001

y= 5 ; z = 0

y= 6 : z = 0

y= 7 : z = 0

y= 8 : z = 0

y= 9 : z = 0

:

:

:

Thanks

Dave

 
20030:

Hi

I have some problem of the simple code listed below


double z;

double base=0.1;

y=Digits;

z=MathPow(base,y);  


When Digits = 5 , which means MathPow(0.1,5) , z becomes 0 , 

it's double value. Too small.

0.00001 ~ 0

try something like

double z = 1000*pow(base,y);