I need get fractional part of double like int and only two numbers. My code
(int)Math.Floor(val * 100 - (int)val * 100)
but this can (int)val * 100
may be out of range of int or long. Ok.
If i try
(int)Math.Floor((val - (int)val) * 100)
Return value may be incorrect. For example:
double val = 56.9;
int retVal = (int)Math.Floor((val - (int)val) * 100);
// retVal = 89, because (val - (int)val) return 0.899999999675
How correct get fractional part of double like int?