Skip to content

Instantly share code, notes, and snippets.

@mike-neck
Created January 11, 2018 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-neck/b967b5140f082500d724ef0d0636a76a to your computer and use it in GitHub Desktop.
Save mike-neck/b967b5140f082500d724ef0d0636a76a to your computer and use it in GitHub Desktop.
2進数の確認
[0,1,2,29,30,31,32]
.collect { [original: it, current: (2 as int) ** it as int, sum: (0..it).collect { (2 as int) ** it as int }.sum()] }
.collect { [original: it.original, current: it.current, chex: Integer.toHexString(it.current), sum: it.sum, shex: Integer.toHexString(it.sum)] }
.each { println it }
[original:0, current:1, chex:1, sum:1, shex:1]
[original:1, current:2, chex:2, sum:3, shex:3]
[original:2, current:4, chex:4, sum:7, shex:7]
[original:29, current:536870912, chex:20000000, sum:1073741823, shex:3fffffff]
[original:30, current:1073741824, chex:40000000, sum:2147483647, shex:7fffffff]
[original:31, current:-2147483648, chex:80000000, sum:-1, shex:ffffffff]
[original:32, current:0, chex:0, sum:-1, shex:ffffffff]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment