Why Float and Double Outputs Are Different?

Why Float and Double Outputs Are Different?

float f = Long.MAX_VALUE; double d = Long.MAX_VALUE; System.out.println("Float max value is : "+ f); System.out.println("Double max value is : "+ d); =============================================== Float max value is : 9.223372E18 Double max value is : 9.223372036854776E18 ===============================================*/ When we assign Long.MAX_VALUE to float and double, both try to store a very large number. But float cannot keep many digits accurately, so Java rounds the value and shows...

Original Source

Read the full article at Dev →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.