I have the following code:
Double i=17.31; long j=(long) (i*100); System.out.println(j);
O/P : 1730 //Expected:1731
1730 //Expected:1731
When you do this kind of long conversion it's floor. Your 17.31 could actually be 17.30999999999 and that's why it resulted in 1730 instead of 1731.
use i = i * 100, then i.longValue() will solve the problem.