1. long number = 564;
2. String str = number+"";
3. char[] num = str.toCharArray();
4. number = number - num[0];
/* The value of number is 511 */
I am trying to subtract the first digit of the number from the number using this piece of code.
During debugging, i found out that the value of num[0] was 53. Can anyone explain what am i missing here.
53is the ASCII code for the character5charis a number in the range 0 to 65535, but the characters (usually visible characters but sometimes "control characters" or other characters that have special meaning) associated with those numbers are defined by Unicode. Here is a link to the first 4096 characters.. Note that the digit 5 is at the position 0x0035 (which is 53 in decimal).Character.getNumericValue(ch). Its intent is more obvious, and works for non-ASCII numbers too.