CMP Binary Magnitude Tool

Binary Comparator Calculator

Compare two unsigned binary numbers and instantly determine whether A is greater than, equal to or less than B. See decimal equivalents, magnitude difference, normalized values, comparison width and the first differing binary position.

A > B A = B A < B Unsigned Comparison First Different Bit Decimal Values
Binary Magnitude Comparator Unsigned Comparison
Enter binary digits 0 and 1 only.
Leading zeros are allowed.
Binary Comparison Result
Relationship
A Decimal
B Decimal
Magnitude Difference
Normalized A
Normalized B
Comparison Width
First Different Bit
First Different Values
Matching Positions
Different Positions
A > B 0
A = B 0
A < B 0
Comparator Analysis

What Is a Binary Comparator Calculator?

A Binary Comparator Calculator compares two binary numbers and determines their relative magnitude. For two values A and B, the result can be A greater than B, A equal to B, or A less than B.

Unlike binary addition or subtraction, a magnitude comparator is mainly designed to produce a logical relationship result. Comparator circuits are widely used in digital electronics, processors, control systems, sorting logic and address matching.

This calculator treats both inputs as unsigned binary integers and also shows decimal values, normalized bit patterns, the absolute magnitude difference and the first bit where the two numbers differ.

Binary Magnitude Comparator Outputs

A Greater Than B

The greater-than output becomes active when A represents a larger unsigned binary value than B.

A > B
GT = 1

A Equal To B

The equality output becomes active when both binary numbers represent exactly the same numerical value.

A = B
EQ = 1

A Less Than B

The less-than output becomes active when A represents a smaller unsigned binary value than B.

A < B
LT = 1

Comparator Flags

For a valid binary comparison, one of GT, EQ or LT identifies the relationship between A and B.

1-Bit Binary Comparator Truth Table

A B A > B A = B A < B
0 0 0 1 0
0 1 0 0 1
1 0 1 0 0
1 1 0 1 0

1-Bit Comparator Boolean Equations

Greater Than

GT = A AND NOT(B)

Less Than

LT = NOT(A) AND B

Equal

EQ = A XNOR B

XNOR Equality

XNOR is commonly used for individual-bit equality because it produces 1 when both inputs have the same state.

How Multi-Bit Binary Comparison Works

For unsigned binary values, comparison begins at the most significant position. If both bits are equal, the comparison continues toward the less significant positions.

The first high-order position where A and B differ determines which binary value is larger.

A = 101101
B = 100111

Compare from the left:
1 = 1
0 = 0
1 > 0

Therefore:
A > B

Worked Example: A Greater Than B

A = 1011
B = 1001

1011 binary = 11 decimal
1001 binary = 9 decimal

11 > 9

GT = 1
EQ = 0
LT = 0

Worked Example: Equal Binary Numbers

A = 110101
B = 110101

All corresponding bits match.

A = B

GT = 0
EQ = 1
LT = 0

Worked Example: A Less Than B

A = 0110
B = 1010

0110 binary = 6 decimal
1010 binary = 10 decimal

6 < 10

GT = 0
EQ = 0
LT = 1

Leading Zeros in Binary Comparison

Leading zeros do not change the value of an unsigned binary integer. Binary 101 and binary 00101 both represent decimal 5.

A = 00101
B = 101

Normalized A = 00101
Normalized B = 00101

A = B

Binary Comparison Examples

A B A Decimal B Decimal Result
0000 0000 0 0 A = B
0001 0000 1 0 A > B
0011 0100 3 4 A < B
0111 0111 7 7 A = B
1000 0111 8 7 A > B
1010 1100 10 12 A < B
1111 1110 15 14 A > B

Binary Comparator vs Binary Subtraction

Feature Binary Comparator Binary Subtraction
Main purpose Determine relationship Calculate difference
Typical output GT, EQ, LT Difference bits
Borrow calculation Not required May be required
Equality Direct result Can be inferred from zero
Typical use Decision logic Arithmetic logic

Where Binary Comparators Are Used

Digital Logic

Comparator circuits generate logical outputs based on the relationship between two binary quantities.

Processor Decisions

Comparison operations support conditional decisions, branches and numerical evaluation inside processors.

Address Matching

Digital systems can compare binary addresses, register values and identifiers.

Sorting and Selection

Comparator circuits can help select larger or smaller values in digital sorting and selection systems.

Important Binary Comparator Notes

Important: this calculator treats both inputs as unsigned binary integers.

Leading zeros do not alter the numerical value.

When inputs have different lengths, the shorter value is padded with leading zeros before bit-by-bit analysis.

For unsigned numbers, the first differing high-order bit determines the larger value.

Signed two’s-complement values require different comparison rules because the most significant bit also represents the sign.

Related BinaryCon Tools

Binary Comparator Calculator FAQs

What is a binary comparator?
A binary comparator determines whether one binary value is greater than, equal to or less than another binary value.
What are the outputs of a binary magnitude comparator?
The common relationship outputs are A greater than B, A equal to B and A less than B.
How do you compare binary numbers?
For unsigned values, compare corresponding bits beginning with the most significant position. The first position where they differ determines the larger value.
What happens if both values are equal?
The equality flag becomes 1 while greater-than and less-than remain 0.
Do leading zeros affect comparison?
No. Leading zeros do not change the numerical value of an unsigned binary integer.
Which gate is commonly used for equality checking?
XNOR is commonly used because it returns 1 when both input bits are the same.
What is the one-bit greater-than equation?
For one-bit inputs, greater-than can be expressed as A AND NOT(B).
What is the one-bit less-than equation?
For one-bit inputs, less-than can be expressed as NOT(A) AND B.
Can binary numbers of different lengths be compared?
Yes. The shorter unsigned value can be padded with leading zeros before comparison.
What is magnitude difference?
Magnitude difference is the absolute numerical difference between the two values.
What is the first differing bit?
It is the highest-order position where the normalized A and B values do not match.
Does this calculator compare signed binary values?
No. This calculator performs unsigned binary magnitude comparison.
Scroll to Top