It seems like the smallest non-zero number that google's calculator can calculate is 2^-1023. I.e. 2^-1024 equal 0.
In JAVA Double.MIN_VALUE is 2^-1074.
When reading about JAVA's Double.MIN_VALUE here and across the Internet there are many mentions of IEEE 754 but none of them actually says that 2^-1074 is the smallest non zero number that is defined in IEEE 754.
So my questions are:
Here is the program I made on these questions:
public class Lecture {
public static void main(String[] args) {
double min = Double.MIN_VALUE;
double max = Double.MAX_VALUE;
double minPlusOne = min + 0.0001;
System.out.println("Min + 1: " + minPlusOne);
System.out.println("Double.MIN_VALUE: " + min);
System.out.println("Double.MIN_VALUE: " + max);
double myMin = Math.pow(2, -1074);
System.out.println("2^-1074: " + myMin);
System.out.println("Double.MIN_VALUE == 2^-1074: " + (min == myMin));
System.out.println();
System.out.println("Changed Min:" + (min + min));
double a = 4.9E-5;
double b = a + a;
System.out.println(b);
}
}
EDIT: As asked, removing the follow up questions.
How does JAVA's Double.MIN_VALUE relate to IEEE 754's definition of the smallest non-zero number? Is there such a thing at all?
You should carefully read a good tutorial on FP numbers for instance what every programmer should know about floating point arithmetic. "Normal" numbers min value is 2^-1023. But IEEE-754 also has "subnormal" (or denormal) numbers whose min value is 2^-1074. These numbers can be smaller but with an important loss of precision.
Why does Google's calculator cannot calculate smaller numbers than 2^-1023 when apparently there are such numbers? (I know people don't use them every day but still, programming languages allow it).
Not all hardware support denormal numbers, and when it is supported using these numbers come with a high temporal cost (for instance on a pentium operator latency for normal numbers is ~5, but can be >100 if the result or one operand is subnormal). That may be the reason why google does not support subnormals (but it is just an hypothesis). FP libraries and hardware have a mean to consider subnormals numbers as zero.
In JAVA, if Double.MIN_VALUE == 4.9E-324 then why (Double.MIN_VALUE + Double.MIN_VALUE) == 1.0E-323 and not 9.8E-324, considering that (4.9E-5 + 4.9E-5) == 9.8E-5?
The printed value is rounded and displayed in binary. Exact value of integer part of 2^-1023 has much more decimals than 4.9. and it is the same for its double. It is a matter of display.
How much should I add to Double.MIN_VALUE in order to make it equal zero?
Just subtract it for itself.