I am trying to extract the integral and fractional parts from a decimal value (both parts should be integers):
decimal decimalValue = 12.34m;
int integral = (int) decimal.Truncate(decimalValue);
int fraction = (int) ((decimalValue - decimal.Truncate(decimalValue)) * 100);
(for my purpose, decimal variables will contain up to 2 decimal places)
Are there any better ways to achieve this?
int
/long
representing "your value multipled by 100". – Elseelset