문제

Hi i want to calculate

2^(256bit number)

in java, but biginteger's pow function just can handle ints.

How can i calculate with larger numbers?

Is there any library?

i want to calculate all numbers from

2^0
2^1
2^2
...
2^(10^77)
도움이 되었습니까?

해결책

I suspect the reason they didn't bother including anything like this is that in most cases, the number would be too big to represent.

Consider 2^(256 bit number). The result has (256bit number) bits, meaning that it takes more memory then there are particles in the universe.

So you'll have to find a different way to represent your logic. Perhaps you could do it symbolically.

It would be possible to do 2^(2^32) and exponents close to that, but this was probably seen as a niche case that they just didn't bother adding a function for.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top