Java Unsigned Number Create unsignedShortAt(byte[] data, int pos)

Here you can find the source of unsignedShortAt(byte[] data, int pos)

Description

Returns the unsigned short that starts at the given position in the given byte array.

License

Open Source License

Declaration

public static final int unsignedShortAt(byte[] data, int pos) 

Method Source Code

//package com.java2s;
/**//from   w  w  w .jav a2s.c o  m
 * Copyright (C) 2010-2014 Fabric project group, Cornell University
 *
 * This file is part of Fabric.
 *
 * Fabric is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 2 of the License, or (at your option) any later
 * version.
 * 
 * Fabric is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 */

public class Main {
    /**
     * Returns the unsigned short that starts at the given position in the given
     * byte array.
     */
    public static final int unsignedShortAt(byte[] data, int pos) {
        return ((data[pos + 0] & 0xff) << 8)
                | ((data[pos + 1] & 0xff) << 0);
    }
}

Related

  1. unsignedNumericToByteArray(long src, int length)
  2. unsignedOneSidedGallopingIntersect2by2(final short[] smallSet, final int smallLength, final short[] largeSet, final int largeLength, final short[] buffer)
  3. unsignedShort(byte b)
  4. unsignedShort(short s)
  5. unsignedShort2Arr(int var, byte[] arrayBytes, int startIndex)
  6. unsignedShortBytesToInt(byte[] b)
  7. unsignedShortToInt(byte[] b)
  8. unsignedShortToInt(final byte[] b)
  9. unsignedShortToInt(short n)