0
2

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 2進数, 8進数, 10進数, 16進数の変換

Posted at

####たまにしか触れなそうなので備忘録としてメモしておきます。

まず、英単語の確認から、、、

2進数 【binary number】
8進数 【octal number】
10進数 【decimal number】
16進数 【hexadecimal number】

qiita.php
$number1 = 55;
    echo decbin($number1)."\n"; //10進数→2進数 110111
    echo decoct($number1)."\n"; //10進数→8進数 67
    echo dechex($number1)."\n"; //10進数→16進数 37
    echo base_convert($number1, 10, 16); //任意の基数を変換 37

$number2 = 100110;

    echo bindec($number2)."\n"; // 2進数→10進数 38
    echo octdec($number2)."\n"; //8進数→10進数 32840
    echo hexdec($number2)."\n"; //16進数→10進数 1048848
    

printf()とかはよくわからないので今後暇見つけて勉強します。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?