Subject: Re: Network mask contiguity

From: "Naidu, Venkata" <[email-masked]>
Date: Mon, 15 Dec 2003 12:09:41 -0500

->   You can check whether "log((~mask)+1)" is a natural number or not.
->   If it is a natural number then mask is contiguous, else it is not.

  Realize the hidden beauty in the above algorithm. If the mask is
  continuous then the result will return the "mask length".
  (32 - log(~mask + 1)) is in fact the mask length. Converting
  back to mask is also straight forward (~(~0 >> masklength)).

Venkata.

---

From: Fred Baker <[email-masked]>
Date: Mon, 15 Dec 2003 09:28:39 -0800

>   back to mask is also straight forward (~(~0 >> masklength)).

yes. It does make some interesting assumptions about floating point
arithmetic that may not actually work on a specific implementation, though.