0
0

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 3 years have passed since last update.

【初心者】PHPで10進数を2進数に変える

Posted at

10進数を2進数に変換したい

簡潔に。

decbin(10進数);

実際に使ってみると…

$str = 18;
echo decbin($str);
// 出力結果
10010

このような感じで、10進数"18"が"10010"と2進数に変えることができた。

逆に2進数を10進数には…

では逆はどうだろうか。

bindec(2進数);

実際に使ってみると…

$str = 10010;
echo bindec($str);
// 以下結果
18

このように2進数を10進数に変えることができた。

簡単に覚えておけそうなので、覚えておく。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?