Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.
Become a Premium Member and unlock a new, free course in leading technologies each month.
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
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.