Separate the network bits from the host bits
An IPv4 address has 32 bits. The prefix says how many belong to the network. The remaining 32 minus prefix bits create 2^(32 − prefix) addresses. The subnet mask has ones for network bits and zeros for host bits; the wildcard mask reverses those bits.
For 192.168.1.20/24, the network is 192.168.1.0, the mask is 255.255.255.0, and the broadcast is 192.168.1.255. The conventional host range runs from 192.168.1.1 to 192.168.1.254, giving 254 hosts. RFC 4632 describes CIDR addressing.
The smallest address blocks need different rules
A /31 has two addresses and can use both on a point-to-point link under RFC 3021. A /32 identifies one address. Neither receives a separate broadcast address in this result.
Larger blocks can contain reserved or otherwise unsuitable addresses. The arithmetic does not check allocation registries, routing policies, or your organization’s network plan.