6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IPアドレスはゼロパディングしてはいけないという話(v4です)

Last updated at Posted at 2016-06-17

知っている人はタイトルだけでわかる内容です。処理系によっては当てはまらないものがあるかもしれません。

突然クイズ

192.168.100.013
このIPアドレスが示すのは?

ping 192.168.100.013

を実行してみよう。

答え

192.168.100.11

何故か?

013の部分はプレフィックス0が指定された8進数として扱われます。ちなみにプレフィックス0xは16進数になります。3桁区切りが気持ちいいからと言ってゼロパディングはダメ絶対!

6
4
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?