hi,
How to get the decimal point of the float or doubld variable.
ex.
100.23 = .23 or 23
.12 = .12 or 12
thanks ,
Popskie
Printable View
hi,
How to get the decimal point of the float or doubld variable.
ex.
100.23 = .23 or 23
.12 = .12 or 12
thanks ,
Popskie
There might be a cleaner way, but this should at least get you the result. Just be aware, that you are boud to get small rounding errors here:
Code:float myFloat = 15.12f;
int myInt = (int)myFloat;
float myAnswer = myFloat - (float)myInt;
An other way could be to cast it to string, and then find the . sign and then use SubString.
- ØØ -
That gives you 0.1199999.
This is equally ugly but gives you 0.12.
Code:float value = 15.12f;
decimal decimalPart = (decimal) value - (decimal) Math.Floor(value);
Math.IEEERemainder(someValue, 1)