{"id":2651,"date":"2017-11-17T18:34:14","date_gmt":"2017-11-17T18:34:14","guid":{"rendered":"http:\/\/webartdevelopers.com\/?p=2651"},"modified":"2017-11-17T18:38:20","modified_gmt":"2017-11-17T18:38:20","slug":"how-to-create-a-program-to-convert-a-decimal-number-into-binary-number-in-core-java","status":"publish","type":"post","link":"https:\/\/webartdevelopers.com\/blog\/how-to-create-a-program-to-convert-a-decimal-number-into-binary-number-in-core-java\/","title":{"rendered":"How to Create a Program to Convert a Decimal Number into Binary Number in Core Java"},"content":{"rendered":"<p>In this tutorial how to convert a decimal number into binary number in Core Java\u00a0 is shown.<\/p>\n<p>Code:<\/p>\n<p>Binary.java<\/p>\n<p>import static java.lang.Math.pow;<\/p>\n<p>class D2B<br \/>\n{<br \/>\npublic static void main(String args[])<br \/>\n{<br \/>\nint number=Integer.parseInt(args[0]),binary=0,r,copyn,i=0;<br \/>\ncopyn=number;<br \/>\nwhile(copyn&gt;0)<br \/>\n{<br \/>\nr=copyn%2;<br \/>\nbinary=binary+(int)(r*pow(10,i++));<br \/>\ncopyn\/=2;<br \/>\n}<br \/>\nSystem.out.println(&#8220;D2B of &#8220;+number+&#8221; is &#8220;+binary);<br \/>\n}<br \/>\n}<\/p>\n<p><a href=\"https:\/\/youtu.be\/6o_Q1Mq7u0Q\">https:\/\/youtu.be\/6o_Q1Mq7u0Q<\/a><\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"In this tutorial how to convert a decimal number into binary number in Core Java\u00a0 is shown. Code: Binary.java import static java.lang.Math.pow; class D2B { public static void main(String args) { int number=Integer.parseInt(args),binary=0,r,copyn,i=0; copyn=number; while(copyn&gt;0) { r=copyn%2; binary=binary+(int)(r*pow(10,i++)); copyn\/=2; } System.out.println(&#8220;D2B of &#8220;+number+&#8221; is &#8220;+binary); } }<!-- AddThis Advanced Settings generic via filter on get_the_excerpt -->","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[156],"tags":[157,166],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2651"}],"collection":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/comments?post=2651"}],"version-history":[{"count":2,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2651\/revisions"}],"predecessor-version":[{"id":2653,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/posts\/2651\/revisions\/2653"}],"wp:attachment":[{"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/media?parent=2651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/categories?post=2651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webartdevelopers.com\/blog\/wp-json\/wp\/v2\/tags?post=2651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}