Java Binary Encode toBinaryString(long value, int bitLegnth)

Here you can find the source of toBinaryString(long value, int bitLegnth)

Description

Helper.

License

Apache License

Parameter

Parameter Description
value to convert the value
bitLegnth length in bits of the return string. starting from index 0 to index (bitLength-1)

Return

String binary representation.

Declaration

private static String toBinaryString(long value, int bitLegnth) 

Method Source Code

//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);
    }
}

Related

  1. toBinaryString(int number)
  2. toBinaryString(int number, int length)
  3. toBinaryString(int value)
  4. toBinaryString(int[] input)
  5. toBinaryString(long val)
  6. toBinaryStringAddress(long address)
  7. toBinaryText(StringBuffer buf)
  8. toBinFromByte(final byte b)
  9. toBinFromHex(final String hexSymbols)