From 4cc28b8dd8d9b8d305e61a334f854217738ae055 Mon Sep 17 00:00:00 2001 From: "Kevin A. Pieckiel" Date: Fri, 6 Jan 2023 18:22:45 -0500 Subject: [PATCH] Change shift left operator to exponent operator to avoid overflow Large numbers of hosts (/0 and /1 subnets) are overflowing and showing as a negative number. Changing 1<<(32-mask) to 2**(32-mask) causes JavaScript to calculate the integer properly. --- subnets.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subnets.html b/subnets.html index c24a7be..aeaf244 100644 --- a/subnets.html +++ b/subnets.html @@ -340,7 +340,7 @@ function network_address(ip, mask) function subnet_addresses(mask) { - return 1<<(32-mask); + return 2**(32-mask); } function subnet_last_address(subnet, mask)