A long bigger than Long.MAX_VALUE

前端 未结 4 1484
天涯浪人
天涯浪人 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:48

    You can't. If you have a method called isBiggerThanMaxLong(long) it should always return false.

    If you were to increment the bits of Long.MAX_VALUE, the next value should be Long.MIN_VALUE. Read up on twos-complement and that should tell you why.

提交回复
热议问题