We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
In Java modulo operation -1 % 3 = -1 , One of the answer said that -1 % 3 =2 But java doesn't calculate like that. How can find result of 2 in -1 % 3
Here the sample java program I run:
class Remainder {
public static void main (String args[]) {
int i = -1;
int j = 3;
System.out.println("i is " + i);
System.out.println("j is " + j);
int k = i % j;
System.out.println("i%j is " + k);
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Kitty and Katty
You are viewing a single comment's thread. Return to all comments →
In Java modulo operation -1 % 3 = -1 , One of the answer said that -1 % 3 =2 But java doesn't calculate like that. How can find result of 2 in -1 % 3 Here the sample java program I run: class Remainder {