title: Output Error:Binary to decimal java
body: <p>The aim of my code was to convert binary numbers(String)n to decimal form
  This program segment compiled succesfully but the output is coming way bigger than expected.</p>
  
  <p>Need some help.Thanks in advance</p>
  
  <pre><code>public class bindecstr {
  public static void main(String args[]){
      String s="11111";
      int l=s.length();
      double sum=0;
      int t=l-1;
  for(int i=0;i&lt;l;i++){   
      char ch=s.charAt(i);
      int x=(int)ch;
      double d=(Math.pow(2,t-i))*x;
      sum=sum+d;
  }
  System.out.println(sum);
  }
  }
  </code></pre>