title: Converting from a char to a long
body: <p>I'm creating a big integer class. I read in two longs as function arguments and what I want to do is have each number in the long read in to occupy one index of an array. </p>
  
  <p>I've done this by converting the long into a string then char array and storing them somewhere temporarily. This works fine and when printed out prints out exactly like the number read in. Now what I want to do is add them now to a new array and have their data type as <code>long</code>. I have made two arrays to deal with this.</p>
  
  <p>Problem is when I try cast the char to a long, it gives me a completely different value. It seems that it's converting the char into it's own respective number? Character class doesn't seem to have any way of converting to a long.</p>
  
  <p>What's the best way to do this?</p>
  
  <p>EDIT: It seems that if I change the long arrays to int arrays and then use Character.getNumericValue(char ch) it works adding it to the array properly.</p>
  
  <p>Since I'm planning to be returning a long at the end of this function should I make sure that those arrays are long for safety? Or storing them as ints in the array is fine? Thanks</p>
  
  <pre><code>public static long hugeMultiplication(long value1, long value2){
      System.out.println("originalvalue: "+value1);
      int lengthOfWordOne = String.valueOf(value1).length();
      int lengthOfWordTwo = String.valueOf(value1).length();
      System.out.println("length1: "+lengthOfWordOne);
      System.out.println("length2: "+lengthOfWordTwo);
  
      long[] numberOne = new long[lengthOfWordOne+1];
      long[] numberTwo = new long[lengthOfWordTwo+1];
  
      //make those longs into string to convert char array
      char[] tempValueOne = String.valueOf(value1).toCharArray();
      char[] tempValueTwo = String.valueOf(value2).toCharArray();
  
      //copy each value of a char array to long array and change to long again
      //this will set up the array having each number in it so we can do the multiplication
      for (int i = 0; i &lt; tempValueOne.length; i++){
          numberOne[i] = (long) tempValueOne[i];
      }
  
  
      for (int i = 0; i &lt; numberOne.length; i++){
          System.out.print(numberOne[i]);
      }
  </code></pre>