Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

BigInteger

 
Nila dhan
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?
 
Barry Gaunt
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...
 
Stan James
(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!
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if BigInteger supports decimal places.
 
Layne Lund
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic