Fastest way to check if two integers are on the same side of 0

后端 未结 6 1532
后悔当初
后悔当初 2021-02-02 10:02

I need to check if two integers are on the same side of zero many times. I don\'t care if it\'s positive or negative, just that it\'s the same side... and performance is very im

6条回答
  •  清歌不尽
    2021-02-02 10:32

     int int1    = 3;
     int int2    = 4;
     boolean res = ( (int1 * int2) >= 0) ? true : false;
    
     System.out.println(res);
    

提交回复
热议问题