Originally published byDev.to
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 a shorter number like 9.223372E18. double has higher precision, so it can store more digits and shows a more accurate value like 9.223372036854776E18. That’s why both outputs are different even though they come from the same value.
🇺🇸
More news from United StatesUnited States
NORTH AMERICA
Related News
Amazon Employees Are 'Tokenmaxxing' Due To Pressure To Use AI Tools
20h ago
UCP Variant Data: The #1 Reason Agent Checkouts Fail
6h ago

Décryptage technique : Comment builder un téléchargeur de vidéos Reddit performant (DASH, HLS & WebAssembly)
16h ago
How Braze’s CTO is rethinking engineering for the agentic area
10h ago
Encryption Protocols for Secure AI Systems: A Practical Guide
20h ago