Does BigInteger ever overflows?

前端 未结 5 424
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-17 13:25

The API docs says

All of the details in the Spec concerning overflow are ignored, as BigIntegers are made as large as necessary to accommodate the r

5条回答
  •  花落未央
    2021-01-17 14:14

    If so why do we let some "type" overflow and some don't?

    That entirely depends on how it is backed. If it's backed by for example a plain vanilla primitive int, then it will obviously overflow at Integer.MAX_VALUE. Primitives have clear overflow borders, while those for Objects depends on how they're backed/programmed.

提交回复
热议问题