/*
 * [TestReverseBytes.java]
 *
 * Summary: Demonstrate use of various ways of reversing byte order.
 *
 * Copyright: (c) 2012-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2011-01-10 initial version
 */
package com.mindprod.example;

import static java.lang.System.*;

/**
 * Demonstrate use of various ways of reversing byte order.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2011-01-10 initial version
 * @since 2011-01-10
 */
public class TestReverseBytes
    {
    /**
     * test harness
     *
     * @param args not used
     */
    public static void main( String[] args )
        {
        int test = 0xabcdef82;  // test value
        out.println( Integer.toHexString( test ) );  // abcdef82
        out.println( Integer.toHexString( Integer.reverseBytes( test ) ) );  // 82efcdab
        test = 0x0000abcd;  // test value
        out.println( Integer.toHexString( Integer.reverseBytes( test ) ) ); // cdab0000 does not work for 16 bits
        out.println( Integer.toHexString( Short.reverseBytes( ( short ) test ) ) ); // ffffcdab, sign extends!
        out.println( Integer.toHexString( Character.reverseBytes( ( char ) test ) ) ); // cdab unsigned.
        }
    }