Groovy web console

subscribe to the feed Subscribe
to this
site
String to EXPRESS Binary (via #groovywebconsole)
tweet this snippet Tweet
this
script

String to EXPRESS Binary

Published 2 months ago by Roch
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def values = ["0", "1", "111011", "100100101010"]
def binaries = []
values.each { value ->
 def i = Integer.parseInt(value, 2)
 def rem = (4 - i.toString().size()%4)%4
 binaries << (rem + Integer.toHexString(i)).toUpperCase()
}
binaries