Quote:
I'm trying to assign the value 12345678.68d to a double variable. But while running the programme, instead of the value I'm trying to assign, the system is assigning 1.234567868E7 to the variable. Surprisingly, as long as I keep the original value to the "one millionth" position, i.e. 1234567.68d,
Both values are the same.
Scientific notation - Wikipedia[
^]
Java Data Types[
^]
[update]
Quote:
So, Java is converting the double value into a scientific number with an "e" to indicate the power of 10.
No, a double value is a double, no matter what.
When a double is converted to string or printed, formatting occurs, and if you don't tell which formatting you want, default formatting is chosen by Java.
By default, if Java try this format 12345678.68 but the size of converted value is bigger than a default number of chars, it switch to 1.234567E7 because it can convert the value with less chars.
Quote:
But question is, how do I change it to 12345678.68 back
You need to say how you want to format the value.
https://mkyong.com/java/how-to-format-a-double-in-java/[
^]