LoginSignup
1
0

More than 5 years have passed since last update.

10進数の数字から2進数の桁数を求める式

Posted at
Math.Floor(Math.Log(["10進数の値"]) / Math.Log(2) + 1);

double digit = Math.Floor(Math.Log(27) / Math.Log(2) + 1);
Console.WriteLine(digit); //5と表示
1
0
1

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