Java Unsigned Number Create unsignedSubOverflow(int operand1, int operand2)

Here you can find the source of unsignedSubOverflow(int operand1, int operand2)

Description

Returns true, if the subtraction of both operand1 - operand2 (both unsigned) will issue a borrow.

License

Open Source License

Declaration

public static boolean unsignedSubOverflow(int operand1, int operand2) 

Method Source Code

//package com.java2s;
/*//from   w  w w  .ja  v a 2 s.c om
 *  This file is part of MRP (http://mrp.codehaus.org/).
 *
 *  This file is licensed to You under the Eclipse Public License (EPL);
 *  You may not use this file except in compliance with the License. You
 *  may obtain a copy of the License at
 *
 *      http://www.opensource.org/licenses/eclipse-1.0.php
 *
 *  See the COPYRIGHT.txt file distributed with this work for information
 *  regarding copyright ownership.
 */

public class Main {
    /** 
     * Returns true, if the subtraction of both operand1 - operand2 (both unsigned) will issue a borrow.
     */
    public static boolean unsignedSubOverflow(int operand1, int operand2) {
        operand1 += Integer.MIN_VALUE;
        operand2 += Integer.MIN_VALUE;

        return operand1 < operand2;
    }
}

Related

  1. unsignedShortAt(byte[] data, int pos)
  2. unsignedShortBytesToInt(byte[] b)
  3. unsignedShortToInt(byte[] b)
  4. unsignedShortToInt(final byte[] b)
  5. unsignedShortToInt(short n)
  6. unsignedToBytes(byte b)
  7. unsignedToSigned(int unsigned, int size)
  8. unsignedToSigned(int[] ints)
  9. unsignedToSigned(int[] unsignedBytes)