W
Wolfgang
I'm trying to detect a very small difference in a math operation, like
this:
double c;
double a;
double b= 3e8;
double result = Math.sqrt(b*b + 100.0) - b;
System.out.println(b + " " + result);
This dispalys a result of
result: 1.7881393432617188E-7
If I increase b to say b=3e9 and greater, result goes to 0;
result: 0.0
I think it's just an underflow, showing zero for very small numbers.
In Java, what can I do to increase the precision?
PS: I know BigInteger, but that obviously won't help me here.
Thanks for your help,
Wolfgang
Santa Barbara, CA
this:
double c;
double a;
double b= 3e8;
double result = Math.sqrt(b*b + 100.0) - b;
System.out.println(b + " " + result);
This dispalys a result of
result: 1.7881393432617188E-7
If I increase b to say b=3e9 and greater, result goes to 0;
result: 0.0
I think it's just an underflow, showing zero for very small numbers.
In Java, what can I do to increase the precision?
PS: I know BigInteger, but that obviously won't help me here.
Thanks for your help,
Wolfgang
Santa Barbara, CA