GivenI calculate "namespace Net { ip(a,b,c,d) = UInt32(a)*16777216 + UInt32(b)*65536 + UInt32(c)*256 + UInt32(d); mask(p) = UInt32(2^32 - 2^(32 - p)); wildcard(p) = bitNot(mask(p)); network(addr, p) = bitAnd(addr, mask(p)); broadcast(addr, p) = bitOr(addr, wildcard(p)); hosts(p) = 2^(32 - p) - 2 }"445µs
AndI calculate "addr = Net::ip(192, 168, 1, 130)"210µs
WhenI calculate "Net::network(addr, 24) == 3232235776"158µs
Thenthe result is "1"36µs
WhenI calculate "Net::broadcast(addr, 24) == 3232236031"152µs
Thenthe result is "1"34µs
WhenI calculate "Net::hosts(24)"84µs
Thenthe result is "254"41µs
WhenI calculate "Net::network(addr, 26) == 3232235904"146µs
Thenthe result is "1"33µs
WhenI calculate "Net::hosts(26)"79µs
Thenthe result is "62"47µs