While converting double to int:
double d = 5.5;
int i = (int) d;
Variable "i" becomes 5. That's exactly what i want, the problem is i am getting the warning: Cast to 'int' from 'double' may result in loss of precision My question is, is there any way to tell IDE that such precision loss is expected so i will not get the warning? So is there any other way to lose precision and cast to integer?
I know that i could disable all loss precision warnings at all, but it wouldn't be nice. I am using Intellij IDEA 13
Consider adding @SuppressWarnings("NumericCastThatLosesPrecision") on your method. This would be a portable solution to your concern.
The best thing is to use Double and Integer. Then you can use intValue() method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With