Q 29. What is the output { Float f1 = new Float("4.4e99f"); Float f2 = new Float("-4.4e99f"); Double d1 = new Double("4.4e99"); System.out.println(f1); System.out.println(f2); System.out.println(d1); } a) Runtime error b) Infinity -Infinity 4.4E99 c) Infinity -Infinity Infinity d) 4.4E99 -4.4E99 4.4E99 Can anybody tell me how to compute it? Thanks
b is correct. You shouldn't know by heart the exact value of Float.MAX_VALUE or Float.MIN_Value but the range for the exponent in base 10 for a float is easy to remember : -38 to 38 Also for a double: -308 to 308
The range for normalized floats is -38 to 38, and for normalized doubles -308 to 308. But Java floating-point representations apparently allow "denormals" as well, which accounts for the MIN_VALUEs given above.