# Issue

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.

# Solution

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
```

Answered By - Nir Levy Answer Checked By - Terry (PHPFixing Volunteer)

## 0 Comments:

## Post a Comment

Note: Only a member of this blog may post a comment.