Comparing Decimals

Decimals are compared in nearly same way as integers.

Steps for comparing decimals:

  1. Find number of digits in integer part of each number. If number of digits is not equal, add required number of LEADING zeros (just like in case of integers).

  2. Find number of digits in fractional (decimal) part of each number. If number of digits is not equal, add required number of TRAILING zeros.

  3. Start comparing digits from left to right (just like in case of integers), ignoring decimal point.

Example 1. Compare 23.99 and 48.05.

Here number of digits in both integer and decimal parts of both numbers is equal, so we do step 3.

The leftmost digits are 2 and 4. Since $$${2}<{4}$$$ then $$${23.99}<{48.05}$$$.

Next example.

Example 2. Compare 0.009 and 45.7.

Integer part of the first number contains only one digit, while integer part of the second contains twh digits. Thus, we add one leading zero to first number.

Fractional part of the second number contains only one digit, while fractional part of the first contains three digits. Thus, we add two trailing zeros to second number.

First number: 00.009.

Second number: 45.700.

Now, compare the leftmost digits 0 and 4. Since $$${0}<{4}$$$ then $$${0.009}<{45.7}$$$.

Next example.

Example 3. Compare 12.567 and 12.789.

As can be seen number of digits in both parts is equal, so we begin to compare digits.

First number: 12.567.

Second number: 12.789.

The leftmost digits are equal (both equal 1).

Move to the right: again digits are equal (both equal 2).

Move to the right: since $$${5}<{7}$$$ then $$${12.567}<{12.789}$$$.

Next example.

Example 4. Compare -23.1 and 15.68.

As always negative number is less than positive, so $$$-{23.1}<{15.68}$$$.

Last example.

Example 5. Compare -1.015 and -1.05.

First compare numbers without sign: 1.015 and 1.05.

Second number has 2 digits in decimal part while first has three digits, so we need to add one trailing zero to the second number.

First number: 1.015.

Second number: 1.050.

Now, compare digits.

The leftmost digits are equal (both equal 1), so move to the right.

Next digits are also equal (both equal 0), so move to the right.

Since $$${1}<{5}$$$ then $$${1.015}<{1.05}$$$.

This means that $$$-{1.015}>-{1.05}$$$.

Now, practice a bit.

Exercise 1. Compare 2.45 and 7.8.

Answer: $$${2.45}<{7.8}$$$.

Next exercise.

Exercise 2. Compare 2.67 and -17.5.

Answer: $$${2.67}>-{17.5}$$$.

Next exercise.

Exercise 3. Compare 35 and 7.89.

Answer: $$${35}>{7.89}$$$. Hint: decimal part of integer is 0 and don't forget to add zeros (35.00 and 07.89).

Next exercise.

Exercise 4. Compare 12.5 and 12.005.

Answer: $$${12.5}>{12.005}$$$. Hint: add trailing zeros.

Last exercise.

Exercise 5. Compare -543.209 and -543.20757.

Answer: $$$-{543.209}<-{543.20757}$$$. Hint: add trailing zeros, ignore signs and then change direction of inequality.