Here you can find the source of swapShort(final short value)
Parameter | Description |
---|---|
value | value to convert |
public static short swapShort(final short value)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .j ava 2 s . c o m * Number of bits on a byte. */ public static final int BIT_SIZE_OF_BYTE = 8; /** * The mask of a byte from an integer. Used to simulate a fast coercion of integer to * byte. */ public static final int INT_LOW_BYTE_MASK = 0x000000FF; /** * Converts a "short" value between endian systems. * * @param value value to convert * @return the converted value */ public static short swapShort(final short value) { final int result = (((value >> 0) & INT_LOW_BYTE_MASK) << BIT_SIZE_OF_BYTE) + (((value >> BIT_SIZE_OF_BYTE) & INT_LOW_BYTE_MASK) << 0); return (short) result; } }