Java Unsigned Number Create unsignedShort(short s)

Here you can find the source of unsignedShort(short s)

Description

unsigned Short

License

Open Source License

Declaration

public static int unsignedShort(short s) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int unsignedShort(short s) {
        byte[] array = shortToByteArray(s);
        int b1 = (0x000000FF & ((int) array[0]));
        int b2 = (0x000000FF & ((int) array[1]));
        return (b1 << 8 | b2);
    }//from  w  w w.j  av  a  2  s .  c  om

    public static byte[] shortToByteArray(short s) {
        return new byte[] { (byte) ((s & 0xFF00) >> 8), (byte) (s & 0x00FF) };
    }
}

Related

  1. unsignedLongToString(long x)
  2. unsignedMediumToBytes(final Long unsignedInt)
  3. unsignedNumericToByteArray(long src, int length)
  4. unsignedOneSidedGallopingIntersect2by2(final short[] smallSet, final int smallLength, final short[] largeSet, final int largeLength, final short[] buffer)
  5. unsignedShort(byte b)
  6. unsignedShort2Arr(int var, byte[] arrayBytes, int startIndex)
  7. unsignedShortAt(byte[] data, int pos)
  8. unsignedShortBytesToInt(byte[] b)
  9. unsignedShortToInt(byte[] b)