title: Reversed Binary Numbers
body: <p>I was trying a little puzzle which i found <a href="https://www.spotify.com/int/jobs/tech/reversed-binary/" rel="nofollow">here</a></p>
  
  <p>and I was wondering how come my answer is incorrect, you see the original specification is</p>
  
  <blockquote>
    <p>Your task will be to write a program for reversing numbers in binary.
    For instance, the binary representation of 13 is 1101, and reversing
    it gives 1011, which corresponds to number 11.</p>
  </blockquote>
  
  <p>So Here is my code..</p>
  
  <pre><code>import java.util.Scanner;
  
  public class ReverseBinary {
  
      public  String reversedIntToBinary(int val) {
          int value = val;
          StringBuilder bldr = new StringBuilder();
  
          while (value != 0) {
              int remainder = value % 2;
              value = value / 2;
              bldr.append(remainder);
          }
          return bldr.toString();
      }
  
      public  int toDecimal(String bin) {
          char[] binString = bin.toCharArray();
  
          int starting = 0;
  
          for (int i = 0; i &lt; binString.length; i++) {
              int tempoVal = starting * 2
                      + Character.getNumericValue(binString[i]);
              starting = tempoVal;
          }
          return starting;
      }
  
      public  int reversedBinary(int val){
          String bin =reversedIntToBinary(val);
          int result = toDecimal(bin);
          return result;
      }
  
      public static void main(String[] args) {
          ReverseBinary rvb = new ReverseBinary();
  
          Scanner input = new Scanner( System.in);
          System.out.println("Enter A Number: ");
          int num = input.nextInt();
          System.out.println(rvb.reversedBinary(num));
      }
  }
  </code></pre>
  
  <p>it is doing the said task, but upon my submission it is wrong. I wondering why it is considered wrong?  have I missed something crucial?</p>