Here you can find the source of longtobinarystring(long wert, int bits)
public static String longtobinarystring(long wert, int bits)
//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(); } }