by Dinesh Thakur Category: array

Explanation of Math.pow():

Pow()method is a static method of math class present in java.lang package.

This method takes two double type argument and returns the value if the 1st argument which is raised to the power of the 2nd argument.


Public static double pow(double dl,double d2)

Algorithm for Convert Binary integer to Decimal Number:

step 1: set p=0, r=0

step 2: read num

step 3: create an integer array a[] of size 20

step 4: repeat through step-7 while num greater than 0

step 5: a[p]=num%l0

step 6: num= num/ 10

step 7: p=p+ 1

step 8: set q=p-l

step 9: set r=0

step 10: repeat through step-12 while q greater than or equals to 0

step 11: r=r+(a[q]*Math.pow(2, q))

step 12: q=q-1

step 13: print r

step 14: Exit


Here is the Java Example for Convert Binary integer to Decimal Number:

import java.util.Scanner;

public class ConvertBintoDec
                 public static void main(String args[])
                 int num,p=0,q,r=0;
                 Scanner sl=new Scanner(;
                 System.out.print("Enter Binary Number : ");
                 int a[]=new int[20];
                                 System.out.print("Decimal Number is :-> "+r);

Convert Binary integer to Decimal Number Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles