Java Unsigned Number Create unsignedMediumToBytes(final Long unsignedInt)

Here you can find the source of unsignedMediumToBytes(final Long unsignedInt)

Description

Converts unsigned integer to a 3 byte array of unsigned bytes

License

Open Source License

Parameter

Parameter Description
unsignedInt representing the unsigned integer

Return

bytes an array of 3 unsigned bytes

Declaration

public static byte[] unsignedMediumToBytes(final Long unsignedInt) 

Method Source Code

//package com.java2s;
/**//from w  w w .  j a  v  a  2s  .  c o m
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

public class Main {
    /**
     * Converts unsigned integer to a 3 byte array of unsigned bytes
     *
     * @param unsignedInt representing the unsigned integer
     * @return bytes an array of 3 unsigned bytes
     */
    public static byte[] unsignedMediumToBytes(final Long unsignedInt) {
        byte[] bytes = new byte[3];
        bytes[2] = (byte) (unsignedInt & 0xFF);
        bytes[1] = (byte) ((unsignedInt >> 8) & 0xFF);
        bytes[0] = (byte) ((unsignedInt >> 16) & 0xFF);
        return bytes;
    }
}

Related

  1. unsignedLocalIntersect2by2Cardinality(final short[] set1, final int length1, final short[] set2, final int length2)
  2. unsignedLong(byte b)
  3. unsignedLongToByteArray(final long value)
  4. unsignedLongToString(long value)
  5. unsignedLongToString(long x)
  6. unsignedNumericToByteArray(long src, int length)
  7. unsignedOneSidedGallopingIntersect2by2(final short[] smallSet, final int smallLength, final short[] largeSet, final int largeLength, final short[] buffer)
  8. unsignedShort(byte b)
  9. unsignedShort(short s)