Puzzle One: Small problems with data operations
1) to avoid using float and double type when the problem requires an exact answer, use the int long bigdecimal type. This is because not all decimals can be represented as exact representations of binary floating-point numbers when operating in Java virtual. Therefore, when doing business calculations (similar to bank calculations) it is recommended to use BigDecimal of course when constructing a double type with a string instead.
2) often divisible. For the process of multiplying multiple numbers: long x =24*60*60*1000*1000 causes an overflow of type int during this operation, because Java does not have an attribute of the target type, so the number of two int is multiplied by the int type. So at the end of the time will be turned to long but in the process of the operation is already overflow so the result will be inaccurate. Workaround the first operand is a destination type.
Java FAQ Series