How to compare two numbers with decimal numbers in Excel?
Supposing there are two columns of decimal numbers, and you just want to compare two numbers in each row by the decimal numbers only as below screenshot shown. How can you quickly solve this job in Excel?
Recommended Excel Productivity Tools
To compare only two decimal numbers between two numbers, you can apply following formulas as you need.
Select a blank cell next to the two numbers you want to compare, type this formula =IF((FLOOR(A1, 0.01)-FLOOR(B1, 0.01))=0,1,-1), press Enter key, and to drag fill handle down to compare two columns. In the calculated results, 1 indicates the two decimal numbers are the same, while -1 marks the two decimal numbers are different. See screenshot:
Note: In above formula, A1 and B1 are the two numbers you want to compare, 0.01 indicates to compare decimal numbers by two digits.
Tip: If you want to round the decimal firstly and then compare, you can use one of following two formulas.
In the formulas, 2 indicates to compare first two digits in decimal numbers, A1 and B1 are the numbers you want to compare.
If you just want to compare decimal numbers by the first two or first n digits, you can apply the Extract Text utility of Kutools for Excel to extract the decimal numbers you need first, and then use a simple formula to compare them.
|Kutools for Excel, with more than 120 handy functions, makes your jobs easier.|
After installing Kutools for Excel, please do as below:（Free Download Kutools for Excel Now!)
1. Select the two columns numbers you want to compare, and click Kutools > Text > Extract Text. See screenshot:
2. In the Extract Text dialog, type .?? into the Text box, and click Add to add this criterion into the Extract list. See screenshot:
3. Only check the new criterion in the Extract list section, and click Ok. Then select a cell to place the extracted decimal numbers, and click OK to finish. See screenshot:
4. In the adjacent cell to the extracted numbers, type this formula =IF((D1-E1)=0,1,-1), type Enter key, and to drag fill handle down to the cells you need. In the results of calculations, 1 indicates the two numbers are the same, -1 shows the numbers are different. See screenshot:
- How to remove leading zeros before decimal point in Excel?
- How to convert decimal hours/minutes to time format in Excel?
- How to convert decimal number to binary/octal/hex number or vice versa in Excel?
- How to generate random decimal/integer numbers in Excel?