A long bigger than Long.MAX_VALUE

前端 未结 4 1508
天涯浪人
天涯浪人 2020-12-10 00:37

How can I get a long number bigger than Long.MAX_VALUE?

I want this method to return true:

boolean isBiggerThanMaxLong(long val) {
    r         


        
4条回答
  •  长情又很酷
    2020-12-10 00:57

    If triangle.lborderA is indeed a long then the test in the original code is trivially true, and there is no way to test it. It is also useless.

    However, if triangle.lborderA is a double, the comparison is useful and can be tested. isBiggerThanMaxLong(1e300) does return true.

      public static boolean isBiggerThanMaxLong(double in){
        return in > Long.MAX_VALUE;
      }
    

提交回复
热议问题