Here you can find the source of toBinaryString(long value, int bitLegnth)
Parameter | Description |
---|---|
value | to convert the value |
bitLegnth | length in bits of the return string. starting from index 0 to index (bitLength-1) |
private static String toBinaryString(long value, int bitLegnth)
//package com.java2s; /* Copyright 2013 Ivan Iljkic * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at/* w w w. j a v a2s . c o m*/ * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ public class Main { /** * Helper. Returns a String of the binary representation of the given value. * @param value to convert the value * @param bitLegnth length in bits of the return string. starting from index 0 to index (bitLength-1) * @return String binary representation. */ private static String toBinaryString(long value, int bitLegnth) { return Long.toBinaryString(value).substring(0, bitLegnth); } }