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
The double value is represented not as 17.31, but as 17.309999999999999. That's why when you multiply it by 100 you get 1730.99999999999999999. After conversion to Long your double value is truncated towards zero. So you get 1730.
double
Long