Here you can find the source of toBinaryFromHex(byte ch)
Parameter | Description |
---|---|
ch | The hex digit. |
public static byte toBinaryFromHex(byte ch)
//package com.java2s; /*//from www . ja va 2 s .com * Copyright 2015 The RPC Project * * The RPC Project licenses this file to you under the Apache License, * version 2.0 (the "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ public class Main { /** * Takes a ASCII digit in the range A-F0-9 and returns * the corresponding integer/ordinal value. * @param ch The hex digit. * @return The converted hex value as a byte. */ public static byte toBinaryFromHex(byte ch) { if (ch >= 'A' && ch <= 'F') return (byte) ((byte) 10 + (byte) (ch - 'A')); // else return (byte) (ch - '0'); } }