/*
 * [TestUnsignedByte.java]
 *
 * Summary: Test unsigned byte calculation.
 *
 * Copyright: (c) 2009-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 2009-01-01 initial version
 */
package com.mindprod.example;

import static java.lang.System.*;

/**
 * Test unsigned byte calculation.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2009-01-01 initial version
 * @since 2009-01-01
 */
public final class TestUnsignedByte
    {
    /**
     * Test unsigned byte calculation
     *
     * @param args not used
     */
    @SuppressWarnings( { "IncompatibleBitwiseMaskOperation" } )
    public static void main( String[] args )
        {
        // 0xca is a negative number considered as a signed byte.
        byte b = ( byte ) 0xca;
        // false, b sign extends, 0xca does not
        out.println( b == 0xca );
        // true, b sign extends, 0xca sign extends
        out.println( b == ( byte ) 0xca );
        // true, b chopped, 0xca does not sign extend
        out.println( ( b & 0xff ) == 0xca );
        // false, b chopped, 0xca sign extends.
        out.println( ( b & 0xff ) == ( byte ) 0xca );
        }
    }