If you take 172.19.40.1
for a second and convert it to binary, then you get 10101100.00010011.00101000.00000001
. So if you ignore the 172.19 part and just concentrate on the 40 part for a minute, you can see that in 00101000, the last three binary digits are 000.
If you cycle through the binary bits you'll see that you get the following:
40 = 00101000
41 = 00101001
42 = 00101010
43 = 00101011
44 = 00101100
45 = 00101101
46 = 00101110
47 = 00101111
Cool, so that means that the last three binary digits encompass every IP address from 172.19.40.xxx through 172.19.47.xxx, where xxx encompasses 0-255. Now since each number in an IP address is 2**8 hosts, another 3 binary digits makes it 2**11, which means that there are 2048 hosts. But since the first and last hosts in a subnet are broadcast addresses, it's 2**11 - 2, which is 2046.
Incidentally, that range from 172.19.40.1 through 172.19.47.254 can be represented as 172.19.40.0/21, which means the first 21 bits of a subnet mask are 1s, or network bits. so there are 11 bits left that are host bits, or 0s. Same calculation: 2**11 - 2 = 2046.
If you don't want to do the manual calculations yourself, you can find a boat load of subnet calculators that will tell you exactly how many hosts in a particular subnet.