
The following example shows the usage of () method.

This method returns the numeric value of the character, as a nonnegative int value -2 if the character has a numeric value that is not a nonnegative integer -1 if the character has no numeric value. Bitwise operator works on bits and performs bit-by-bit operation. Public static int getNumericValue(char ch)Ĭh − the character to be converted Return Value Java defines several bitwise operators, which can be applied to the integer types, long, int, short, char, and byte. For more information on Unicode terminology, refer to the Unicode Glossary. Declarationįollowing is the declaration for () method In the Java SE API documentation, Unicode code point is used for character values in the range between U+0000 and U+10FFFF, and Unicode code unit is used for 16-bit char values that are code units of the UTF-16 encoding. If the character has a numeric value that cannot be represented as a nonnegative integer (for example, a fractional value), then -2 is returned. If the character does not have a numeric value, then -1 is returned. This is independent of the Unicode specification, which does not assign numeric values to these char values. The Math class in Java is declared as a final class and all the utility methods are defined as static. Math class in Java provides utility methods to do basic numeric operations like calculating square roots, exponential and logarithm.
#JAVA CHAR MATH HOW TO#
Also, the standard ASCII characters range from 0 to 127. Java Math class tutorial with examples will help you understand how to use the Java Math class in an easy way.

The Size of a Java char is 16-bit and the range is between 0 to 65,536. alphabets and numbers in a character set.

The letters A-Z in their uppercase ('\u0041' through '\u005A'), lowercase ('\u0061' through '\u007A'), and full width variant ('\uFF21' through '\uFF3A' and '\uFF41' through '\uFF5A') forms have numeric values from 10 through 35. Java char The data type char comes under the characters group that represents symbols i.e. For example, the character '\u216C' (the roman numeral fifty) will return an int with a value of 50. The (char ch) returns the int value that the specified Unicode character represents.
