To calculate subnetting for given IP address and the subnet address, we do AND operation first to get the network address and the first usable IP address of the subnet. Why do we use AND? I know it gives us a viable answer like such as OR or XOR wouldn't give us answers. But why?
Also, to calculate the last usable address in subnet, we invert the subnet first then use OR operation on it. What is the mathematical logic behind this?
I have been calculating subnets for months. But I have never learnt why do we use AND and OR operations in subnetting. I will teach subnetting today but I have realized I have no answer if they ask me WHY about it. I am also kinda ashamed I never asked these before.