Skip to content

Instantly share code, notes, and snippets.

@libitte
Created April 13, 2014 09:13
Show Gist options
  • Select an option

  • Save libitte/10575858 to your computer and use it in GitHub Desktop.

Select an option

Save libitte/10575858 to your computer and use it in GitHub Desktop.
== 10進法 -> 2進法, 2進法 -> 10進法
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1210460042
- 2 -> 10
ex) 1111001
1*2^6 + 1*2^5 + 1*2^4 + 1*2^3 + 1*2^0
64+32+16+8+1
=121
- 10 -> 2
ex) 45
1, 2, 4, 8, 16, 32, 64, 128
6桁目にbitを建てる
45 - 32 = 13
4桁目にbitを建てる
13 - 8 = 5
3桁目にbitを建てる
5 - 4 = 1
1桁目にbitを建てる
1 - 1 = 0
ans. 101101
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment