Java Binary Encode toBinary(short value)

Here you can find the source of toBinary(short value)

Description

to Binary

License

Open Source License

Declaration

public static String toBinary(short value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toBinary(short value) {
        return String.format("%16s", Integer.toString(value & 0xFFFF, 2)).replace(' ', '0');
    }//from w w  w .ja v  a 2  s  . c  om

    public static String toBinary(byte value) {
        return String.format("%8s", Integer.toString(value & 0xFF, 2)).replace(' ', '0');
    }
}

Related

  1. toBinary(int number, int length)
  2. toBinary(int val)
  3. toBinary(int value, int bits)
  4. toBinary(long l, int bits)
  5. toBinary(long v, int len)
  6. toBinaryAddress(int index, int maxIndex)
  7. toBinaryArray(int input, int length)
  8. toBinaryArray(int integer, int size)
  9. toBinaryBoolean(boolean source)