Java Binary Encode toBin(int x)

Here you can find the source of toBin(int x)

Description

to Bin

License

Open Source License

Declaration

private static StringBuffer toBin(int x) 

Method Source Code

//package com.java2s;

public class Main {
    private static StringBuffer toBin(int x) {
        StringBuffer result = new StringBuffer();
        result.append(x % 2);//from  w w w  .j  a  v a2s.  com
        x /= 2;
        while (x > 0) {
            result.append(x % 2);
            x /= 2;
        }
        return result;
    }
}

Related

  1. toBin(byte n)
  2. toBin(int bin, int size)
  3. toBin(int size, String bitString)
  4. toBin(long value, int width)
  5. toBinArray(String hexStr)
  6. toBinary(byte b)
  7. toBinary(byte b)