1

On my computer, the following line:

System.Net.IPAddress result = default(System.Net.IPAddress);
bool success = System.Net.IPAddress.TryParse("234.34.034.004", out result);

creates the following results

  1. success evaluates to true
  2. The IP Address result returned is 234.34.28.4

What is happening?

1
  • 34 in decimal form is 22 in hex, so that doesn't describe what's happening Commented Sep 30, 2019 at 22:02

1 Answer 1

1

It appears that the "34" is being interpreted as octal because it has a leading zero. (The 4 probably also is being interpreted as octal, but its representation is the same in both bases).

34 in octal is 28 in decimal, thus the output.

Sign up to request clarification or add additional context in comments.

1 Comment

Quite possibly because (winsock) inet_addr does so although System.Net.IPAddress doc doesn't say so.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.