Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 1
    "192.168.56 will be 192.168.0.56 because 0*256^1 + 58*256^0 = 58" Are you sure? You would expect 168 to be multiplied by 256^1 in the first case, and by 256^2 in the second case. Similarly 192 would be multiplied by 256^2 vs. 256^3. So 192.168.56 could only = 192.168.0.56 if there are additional rules in place, such as the dropping of zeroes. Commented Oct 12, 2012 at 14:35
  • @LarsH, I think what's being said here is that it's left-to-right based, unlike "normal" counting where we base everything from the 1's place. So the first dot causes whatever is to the left of it to be multiplied by 256^3, the second by 256^2, the third by 256. if there's no dot to the left of it then it's added w/o multiplying by 256^n. So 1.2.3. (1.2.3.0) would be different than 1.2.3 (1.2.0.3), if I understand correctly. Commented Oct 12, 2012 at 14:59
  • @iX3: if that were the case, then "192.168.56 will be 192.168.0.56" would be incorrect, because in the first case, 56 would be multiplied by 256^1, whereas in the second case, 56 would only be multiplied y 256^0. And the OP's 192.168.072 would be interpreted as 192.168.58.0 instead of 192.168.0.58. Commented Oct 12, 2012 at 15:02
  • What's a bit misleading is the fact the the address has 0 has the 3rd digit. Consider this address 192.168.1.56 The 3 digit form would be 192.168.312 Because 1*256^1 + 56*256^0 is 312 Commented Oct 12, 2012 at 15:40
  • 1
    The dots only serve to delineate which numbers should be multiplied by which power of 256. The parser looks for the first dot, and multiplies the number before it by 256^3. Repeat for 2nd and 3rd dot, but by 256^2 and 256^1, respectively. Then it adds all of the results together (some impl. may keep a running total instead, though the result is the same). If any of those dots are missing, it simply doesn't do the multiplication and just adds the final number to the running total. That's also why 1.2.3. results in an error, because the parser can't find the last number to add to the total. Commented Oct 12, 2012 at 16:26