# what is the use of AND/XOR ?!

sattar
Posts:

**48**Member ■■□□□□□□□□
in CCNA & CCENT

Hello everyone,

I want to know what is the use of AND/XOR in wildcard masks? :

Is it for summarizing ip addresses the most efficient way? :

Am i getting it right?

Thanks in advance

I want to know what is the use of AND/XOR in wildcard masks? :

Is it for summarizing ip addresses the most efficient way? :

Am i getting it right?

Thanks in advance

0

## Comments

15Member ■□□□□□□□□□About 20 or more years ago, I studied Assembly Language. This was before routers or IPs. As you know, Computers are based on 1s and 0s. It would be redundant to change 8 bits to a decimal number to compare, so, it would be easier to just do an AND function to find if there is no difference between two numbers.

I know for certain the operations are used in comparing one number to another. Also, because I didn't learn Assembly language fully, I'm not 100% certain, but AND, Or, XOR operations might be used to add, subtract, binary numbers by moving bits to the left or right.

1,057MemberOh and @Avocado simple add and subtracts in assembly generally use shift left and shift right operators for speed.

1,340MemberExample of XOR Exchange:

A = A XOR B

B = B XOR A

A = A XOR B

A = AD, B = CE

A = AD XOR CE = 63

B = CE XOR 63 = AD

A = 63 XOR AD = CE

A = CE, B = AD

Example of AND Mask:

Let's say you have the number 10 (A in hexadecimal) and wanted to know whether a certain bit was a 1 or 0, you could

A AND (2^N)

For example...

A AND (2^0) = 0

A AND (2^1) = 2

A AND (2^2) = 0

A AND (2^3) = 8

If the result is non-zero then the bit is a one. In this case A (Hexadecimal) is 1010 (Binary).

R&S: CCENT→CCNA→CCNP→ CCIE [ ]Security:CCNA [ ]Virtualization:VCA-DCV [ ]