Example usage for java.lang Integer divideUnsigned

List of usage examples for java.lang Integer divideUnsigned

Introduction

In this page you can find the example usage for java.lang Integer divideUnsigned.

Prototype

public static int divideUnsigned(int dividend, int divisor) 

Source Link

Document

Returns the unsigned quotient of dividing the first argument by the second where each argument and the result is interpreted as an unsigned value.

Usage

From source file:Main.java

public static void main(String[] args) {
    // Two negative integer values
    int x = -1;/*from  w w w.j a  v a2  s  .  c om*/
    int y = -2;

    // Performs signed division
    System.out.println("Signed x = " + x);
    System.out.println("Signed y = " + y);
    System.out.println("Signed x/y  = " + (x / y));

    // Performs unsigned division by treating x and y holding unsigned values
    long ux = Integer.toUnsignedLong(x);
    long uy = Integer.toUnsignedLong(y);
    int uQuotient = Integer.divideUnsigned(x, y);
    System.out.println("Unsigned x  = " + ux);
    System.out.println("Unsigned y  = " + uy);
    System.out.println("Unsigned x/y  = " + uQuotient);
}

From source file:com.amazon.janusgraph.diskstorage.dynamodb.DynamoDBDelegate.java

public static final int computeWcu(int bytes) {
    return Math.max(1, Integer.divideUnsigned(bytes, ONE_KILOBYTE));
}