java - Is it possible to lose precision while calulating 1/val twice? -


if have double d; if do:

d = 1/d; d = 1/d; 

is possible lose precision? in case example?

yes, ofcourse it's possible loose precision. floating-point types such float , double not infinitely precise.

double d = 123456789.0;  system.out.println(d); d = 1 / d; d = 1 / d; system.out.println(d); 

output:

1.23456789e8 1.2345678899999999e8 

Comments

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -