Groovy web console

subscribe to the feed Subscribe
to this
site

FinalNyi

Published 3 weeks ago by Nyi with tags Nyyyyi
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def field= 1049088

def binary = new Integer[32];
int maskBit=1;

for(int i=0; i<32; i++) {
    print("  " + i); 
    binary[i] = 0; // init all to 0
}

println()

for(int i=0; i<32; i++) {
    if(field & maskBit) {
        binary[i] = 1
    }

    maskBit*=2;         
}

println(binary)