convert decimal to binary

Posted sea-stream

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了convert decimal to binary相关的知识,希望对你有一定的参考价值。

 

public class Solution {
    public static void main(String[] args) {
        int dNum = 1264;
        String str = "";
        while (dNum > 0) {
            int rem = dNum % 2;
            str = rem + str;
            dNum = dNum / 2;
        }
        System.out.println("Binary value is: " + str);
    }
}



OUTPUT:
Binary value is: 10011110000

 

以上是关于convert decimal to binary的主要内容,如果未能解决你的问题,请参考以下文章

convert decimal to binary using inbuilt function

[Algorithm] Convert a number from decimal to binary

LeetCode --- 1290. Convert Binary Number in a Linked List to Integer 解题报告

Convert Sorted Array to Binary Search Tree & Convert Sorted List to Binary Search Tree

Convert Sorted Array to Binary Search Tree

C# Newtonsoft.Json.JsonReaderException:“Could not convert string to decimal: