How to separate double into two integer number? First number before and second number after decimal point. For example:
double doub = 543.345671;
int num1 = (int) doub; //543
int num2 = getNumAfterDecimal(doub-num1); //return 345671
I need decimal part to integer.
It depends how many digits you want after the decimal point, but this is the gist:
double d = doub - (int)doub; // will give you 0.xyz
int result = d * 1000; // this is for 3 digits, the number of zeros in the multiplier decides the number of digits