Here you can find the source of getBinaryString(long src)
Parameter | Description |
---|---|
src | a parameter |
public static String getBinaryString(long src)
//package com.java2s; public class Main { /**/*ww w. j a v a 2 s . com*/ * 7 => 00000111 * * @param src * @return */ public static String getBinaryString(long src) { String binaryString = Long.toBinaryString(src); String temp = ""; for (int i = 0; i < Long.SIZE - binaryString.length(); i++) { temp += "0"; } binaryString = temp + binaryString; return binaryString; } /** * 7 => 00000111 * * @param src * @return */ public static String getBinaryString(byte src) { String binaryString = Integer.toBinaryString(src); if (binaryString.length() > Byte.SIZE) { binaryString = binaryString.substring(binaryString.length() - Byte.SIZE); } else { String temp = ""; for (int i = 0; i < Byte.SIZE - binaryString.length(); i++) { temp += "0"; } binaryString = temp + binaryString; } return binaryString; } }