0

I got a range of values from 1.2, 2.2, ... up to 16.2. I tried to separate each value in Excel.

  • In the cell A1, I put a value (1.2).
  • In the cell B1, I put formula =FLOOR(A1,1) to get the integer part.
  • In the cell C1, I put formula =A1-B1 to get the decimal part.
  • In the cell D1, I put formula =IF(C1=0.2,1,0) to examine the decimal part.
  • D1 returned 1 for the values from 1.2 up to 7.2, but D1 returned 0 for the rest of values from 8.2 up to 16.2 and more.

Please tell me what is wrong?

2
  • 1
    You may be running into floating point problems. Try using =IF(A1=B1,1,0) instead Commented Feb 3, 2020 at 16:15
  • I tried your method and it works. Thank you.
    – tesla kan
    Commented Feb 4, 2020 at 3:10

1 Answer 1

0

As said cybernetic.nomad, with floating point you must to be careful, excel shows one but behind scene is another. In this case, the safest way to avoid this is to round the subtraction result to the required accuracy in C1:

=ROUND(A1-B1,1)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .