Tutorial by Examples

You should be careful when comparing floating-point values (float or double) using relational operators: ==, !=, < and so on. These operators give results according to the binary representations of the floating point values. For example: public class CompareTest { public static void main...
Float data type The float data type is a single-precision 32-bit IEEE 754 floating point. Float overflow Maximum possible value is 3.4028235e+38 , When it exceeds this value it produces Infinity float f = 3.4e38f; float result = f*2; System.out.println(result); //Infinity Float Und...
Floating point Numbers can be formatted as a decimal number using String.format with 'f' flag //Two digits in fracttional part are rounded String format1 = String.format("%.2f", 1.2399); System.out.println(format1); // "1.24" // three digits in fractional pa...
By default, floating point operations on float and double do not strictly adhere to the rules of the IEEE 754 specification. An expression is allowed to use implementation-specific extensions to the range of these values; essentially allowing them to be more accurate than required. strictfp disable...

Page 1 of 1