In this answer we can see that Java has a peculiarity when displaying the result in certain types of operations with types primitives that have a floating point, such as division by multiples of 10, which can be seen in the example taken from the linked question, below:
int num1 = 5;
float num2 = num1 / 10000f;
System.out.println(num2);
Since it can be seen here , the result is 5.0E-4
and not 0.0005.
I understand that this is a scientific notation, which means 5.0 * 10^-4
, which leads to the same value, but I did not understand why Java makes this change in the display.
In the linked response, there is an excerpt from the documentation that says:
(...) When the magnitude of the value is less than 10 ^ -3 or greater than 10 ^ 7 the value will be displayed with scientific notation.
Is there any official convention or motive for the language to adopt this type of display in the case mentioned in the citation? Or as stated in the answer, is it just for readability?
Note: This feature does not occur with types
int
andlong
, as can be seen here