KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > util > NumberKit


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.util;
11
12 /**
13  * Utility routines related to numbers.
14  *
15  * @author Klaus Meffert
16  * @since 3.2
17  */

18 public class NumberKit {
19   /** String containing the CVS revision. Read out via reflection!*/
20   private final static String JavaDoc CVS_REVISION = "$Revision: 1.1 $";
21
22   /**
23    * Returns the hex value of "c" or -1 if there is no corresponding hex value.
24    *
25    * @param c hex character to convert
26    * @return integer value of the character
27    *
28    * @author taken from somewhere
29    * @since 3.2
30    */

31   public static int hexValue(char c) {
32     if ('0' <= c && c <= '9') {
33       return c - '0';
34     }
35     if ('A' <= c && c <= 'F') {
36       return c - 'A' + 10;
37     }
38     if ('a' <= c && c <= 'f') {
39       return c - 'a' + 10;
40     }
41     return -1;
42   }
43 }
44
Popular Tags