Does valueOf for BigInteger have any limitations ? I’m not sure but read somewhere, that given number can be of length = long only.
Does valueOf for BigInteger have any limitations ? I’m not sure but read somewhere,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
BigIntegerclass itself is used to represent immutable arbitrary-precision integers. Meaning it can represent integers of any size (limited of course by the memory on your computer).However the
valueOfmethod returns aBigIntegerwhose value is equal to that of the specified long. So aBigIntegercreated in this way by definition can only be a large asLong.MAX_VALUEBigIntegerobjects created by the other methods and constructors of theBigIntegerclass can of course be larger thanLong.MAX_VALUE.Take for example the code snipped below:
The
BigIntegernamedbig3is larger thanLong.MAX_VALUEeven though its constituent parts were created using thevalueOfmethod.