/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
@Test public void testSwapLong() { assertEquals( 0, EndianUtils.swapLong( 0 ) ); assertEquals( 0x0807060504030201L, EndianUtils.swapLong( 0x0102030405060708L ) ); assertEquals( 0xffffffffffffffffL, EndianUtils.swapLong( 0xffffffffffffffffL ) ); assertEquals( 0xab, EndianUtils.swapLong( 0xab00000000000000L ) ); }
/** * Tests all swapXxxx methods for symmetry when going from one endian * to another and back again. */ @Test public void testSymmetry() { assertEquals( (short) 0x0102, EndianUtils.swapShort( EndianUtils.swapShort( (short) 0x0102 ) ) ); assertEquals( 0x01020304, EndianUtils.swapInteger( EndianUtils.swapInteger( 0x01020304 ) ) ); assertEquals( 0x0102030405060708L, EndianUtils.swapLong( EndianUtils.swapLong( 0x0102030405060708L ) ) ); final float f1 = Float.intBitsToFloat( 0x01020304 ); assertEquals( f1, EndianUtils.swapFloat( EndianUtils.swapFloat( f1 ) ), 0.0 ); final double d1 = Double.longBitsToDouble( 0x0102030405060708L ); assertEquals( d1, EndianUtils.swapDouble( EndianUtils.swapDouble( d1 ) ), 0.0 ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }
/** * Converts a "double" value between endian systems. * @param value value to convert * @return the converted value */ public static double swapDouble(final double value) { return Double.longBitsToDouble( swapLong( Double.doubleToLongBits( value ) ) ); }