With monday.comâ€™s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.
int pos =1;
int neg =- 1;
int sum;
String result;
sum = (Integer.signum(pos)+Integer.signum(neg));
System.out.println(result = sum>0?"Both Positive":sum<0?"Both Negative":"One is negative, one positive");
if(Integer.signum(a) == -1){System.out.println(" a is negative");}
else{System.out.println("a is positive");}
what is the return type of the signum()
public boolean posNeg(int a, int b, boolean negative) {
if(Integer.signum(a)!=Integer.signum(b)){
return true;
}
if(Integer.signum(a)==-1 & Integer.signum(b)==-1 & negative==true){
return true;
}
return false;
}
Returns the signum function of the specified int value
public boolean posNeg(int a, int b, boolean negative) {
if(negative==true){
return (a<0&& b<0);
}
if((a>0&&b<0)||(a<0&&b>0)){
return true;
}
return false;
}
public boolean posNeg(int a, int b, boolean negative) {
if (negative) {
return (a < 0 && b < 0);
}
else {
return ((a < 0 && b > 0) || (a > 0 && b < 0));
}
}
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.