title: multiplying bigintegers without bigintegers
body: <p>Hey' all so im figuring out how to multiply bigintegers without importing them and I have it almost all. The only thing that isnt working is when multiplying with -digit the output is still +. any help appreciated. ie. -20*4=80</p>
  <pre><code>    Scanner scan = new Scanner(System.in);
      System.out.println(&quot;Type the first number:&quot;);
      String x = scan.nextLine();
      
      System.out.println(&quot;Type the second number:&quot;);
      String y = scan.nextLine();
  
      if (x.charAt(0) == '-' &amp;&amp; y.charAt(0) != '-') {
          x = x.substring(1);
      }
      else if (x.charAt(0) != '-' &amp;&amp; y.charAt(0) == '-') {
          y = y.substring(1);
      }
      else if (x.charAt(0) == '-' &amp;&amp; y.charAt(0) == '-') {
          x = x.substring(1);
          y = y.substring(1);
      }
      
      String s1 = new StringBuffer(x).reverse().toString();
      String s2 = new StringBuffer(y).reverse().toString();
      
      int[] m = new int[s1.length() + s2.length()];
      
      for (int i=0; i&lt;s1.length(); i++) {
          for (int j=0; j&lt;s2.length(); j++) {
              m[i+j] = m[i+j] + (s1.charAt(i) - '0') * (s2.charAt(j) - '0');
          }           
      }
      
      String product = new String();
      
      for (int i=0; i&lt;m.length; i++) {
          int digit = m[i] % 10;
          int carry = m[i] / 10;
          if (i+1 &lt; m.length) {
              m[i+1] = m[i+1] + carry;
          }
          product = digit + product;
      }
      
      while (product.length() &gt; 1 &amp;&amp; product.charAt(0) == '0') {
          product = product.substring(1);
      }
      
      if (x.charAt(0) == '-' &amp;&amp; y.charAt(0) != '-') {
          product = new StringBuffer(product).insert(0, '-').toString();
      }
      else if (x.charAt(0) != '-' &amp;&amp; y.charAt(0) == '-') {
          product = new StringBuffer(product).insert(0, '-').toString();
      }
      else if (x.charAt(0) == '-' &amp;&amp; y.charAt(0) == '-') {
          product = product;
      }
      System.out.println(&quot;The multiplication of\n&quot; + x + &quot; \nand\n&quot; + y + &quot; &quot; + &quot;\nis\n&quot; + product);
      
      scan.close();
  }
  </code></pre>
  <p>}</p>