Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    public static void main(String[] args) {
        // Two negative integer values
        int x = -1;
        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);
    }
}