Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java integer to binary string

int n = 1000;
String s = Integer.toBinaryString(n);
Comment

java int to binary string

public static String makeBinaryString(int n) {
	StringBuilder sb = new StringBuilder();
	while (n > 0) {
    sb.append(n % 2);
		n /= 2;
	}
  	sb.reverse();  	
  	return sb.toString();
}
Comment

java decimal to binary converter

public class decToBin{

    static void ab(int iput){
        String output = "";
        if(iput <= 0){
            System.out.println("nope");

        }else{
            int a = iput;
            for(int i = 0; a > 0; i++){
                a = Math.floorDiv(a, 2);
                output = (a % 2) + output;
            }
        }

        String b = "";
        String c = "";
        for (int index = 0; index < output.length(); index++) {
            c = output.charAt(index) + c;
        }

        System.out.println(c);
    }




    public static void main(String[] args) {
        System.out.println("test..");
        ab(50);
    }
}
Comment

int to binary java

String binary = Integer.toBinaryString(num);
Comment

integer to binary java

Integer.toString(100,8) // prints 144 --octal representation

Integer.toString(100,2) // prints 1100100 --binary representation

Integer.toString(100,16) //prints 64 --Hex representation
Comment

PREVIOUS NEXT
Code Example
Java :: why python is slower than java 
Java :: java compare two lists ignore case 
Java :: jenna fischer that 70s show 
Java :: concurrent modification exception 
Java :: jsp import 
Java :: javafx textarea new line with shift+enter 
Java :: error: package androidx.multidex does not exist 
Java :: java random Double between 
Java :: primefaces custom validate 
Java :: Convert Octal to Binary in java 
Java :: how to get path of captured image in android 
Java :: bat artifact 
Java :: java eliminate numbers from string 
Java :: play sound on button click android studio 
Java :: android studio fab icon color 
Java :: file to image javafx 
Java :: java random string 
Java :: java list to set 
Java :: how to change maven java version in po, 
Java :: android studio remove notification bar 
Java :: how to count lines from txt java 
Java :: procedural programming Java code example 
Java :: java run shell command 
Java :: javadoc link to class 
Java :: how to change background tint color programmatically android 
Java :: spring boot hibernate log sql 
Java :: java resource file 
Java :: java charsequence to string 
Java :: how to find the largest number in a 2d array java 
Java :: get absolute path from relative java 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =