Here you can find the source of toByte(final int highNibble, final int lowNibble)
Parameter | Description |
---|---|
highNibble | the higher nibble |
lowNibble | the lower nibble |
public static byte toByte(final int highNibble, final int lowNibble)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from w w w.ja v a 2 s.c om*/ * Number of bits on a nibble. */ public static final int BITS_SIZE_OF_NIBBLE = 4; /** * The mask for the low nibble of a byte. */ public static final int INT_BYTE_LOW_NIBBLE_MASK = 0x0000000F; /** * Composes a byte from two nibbles. * * @param highNibble the higher nibble * @param lowNibble the lower nibble * @return a byte composed of the specified nibbles */ public static byte toByte(final int highNibble, final int lowNibble) { final int result = ((highNibble & INT_BYTE_LOW_NIBBLE_MASK) << BITS_SIZE_OF_NIBBLE) | (lowNibble & INT_BYTE_LOW_NIBBLE_MASK); return (byte) result; } }