Skip to content

Instantly share code, notes, and snippets.

@djk29a
Created March 4, 2013 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djk29a/5084533 to your computer and use it in GitHub Desktop.
Save djk29a/5084533 to your computer and use it in GitHub Desktop.
scala> for(masked <- 0 until 8) { println("Bits: 0xff & masked bits (" + masked + ") => " + (256 - (255 & (1 << masked)))) }
Bits: 0xff & masked bits (0) => 255
Bits: 0xff & masked bits (1) => 254
Bits: 0xff & masked bits (2) => 252
Bits: 0xff & masked bits (3) => 248
Bits: 0xff & masked bits (4) => 240
Bits: 0xff & masked bits (5) => 224
Bits: 0xff & masked bits (6) => 192
Bits: 0xff & masked bits (7) => 128
@djk29a
Copy link
Author

djk29a commented Oct 9, 2015

Just wanted a quick reference for reminding myself how easy IPv4 subnet masking is when it's 3 am and I'm beating my head on trivial networking problems that shouldn't be that hard when I'm being sane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment