package com.mindprod.example;

/**
 * Test unsigned byte calculation
 * <p/>
 * composed with IntelliJ IDEA
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0
 */
public final class TestUnsignedByte
    {
    // --------------------------- main() method ---------------------------

    /**
     * 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
        System.out.println( b == 0xca );

        // true, b sign extends, 0xca sign extends
        System.out.println( b == ( byte ) 0xca );

        // true, b chopped, 0xca does not sign extend
        System.out.println( ( b & 0xff ) == 0xca );

        // false, b chopped, 0xca sign extends.
        System.out.println( ( b & 0xff ) == ( byte ) 0xca );
        }
    }