Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

BigInteger  RSS feed

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"BigInteger supports arbitrary-precision integers" .What does this statement mean actually?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It means that you can try to compute numbers like (BigInteger.TEN.pow(Integer.MAX_VALUE)).pow(Integer.MAX_VALUE) and your program will actually try to do it. My computer has been running at 100% CPU for the last 10 minutes doing the calculation...
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need to compute something to 37 decimal places, it'll do it! Whee!
 
Sheriff
Posts: 9087
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if BigInteger supports decimal places.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I recall correctly, the primitive int type uses 4 bytes and long uses 8 bytes. This means that the largest value you can hold in an int is just over two trillion and the largest value in a long is just under 2*10^19. If you need to store numbers larger than this, you can use BigInteger. That is what the statement means.

Layne
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, typing faster than I'm reading again. In my "first love" langauge, REXX, arbitrary precision includes decimal places.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Stan James:
Oops, typing faster than I'm reading again. In my "first love" langauge, REXX, arbitrary precision includes decimal places.



That's what BigDecimal is for.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!