Java Long to longtobinarystring(long wert, int bits)

Here you can find the source of longtobinarystring(long wert, int bits)

Description

longtobinarystring

License

Open Source License

Declaration

public static String longtobinarystring(long wert, int bits) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 EmbSysRegView/*from   w ww .j a  va 2  s.  co  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     ravenclaw78 - initial API and implementation
 *******************************************************************************/

public class Main {
    public static String longtobinarystring(long wert, int bits) {
        StringBuilder text = new StringBuilder();

        for (int i = bits; i > 0; i--) {
            text.append(Math.abs(wert % 2));
            wert /= 2;
        }
        text.reverse();
        return text.toString();
    }
}

Related

  1. longToBasicType(long l, Class clazz)
  2. longToBcd(long num, int size)
  3. longToBcd(long src, int len, int flag)
  4. longToBigEndian(long value, byte[] in, int offset)
  5. longToBinary(long num)
  6. longToBinaryStringUnsigned(long value)
  7. longToBucket(long key, int buckets)
  8. LongToBuf4(long val, byte[] buf, int offset)
  9. longToBuffer(long l, byte[] ioBuffer)