• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing really big numbers (i.e. 640 bytes)

 
Justin Porter
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A long is pretty long, but not long enough. I'm working on cryptography right now and I'm trying to figure out how to store very large numbers (with 250 or so digits) using primitive or non-primitive data types. If I was to use a non-primitive data type, could I still do basic mathematical computations with it? How would I go about doing this? Thanks!
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in Java, integers that size will not fit into any primitive data type, no. the standard library does have a class to handle them (BigInteger, in java.math). but this being Java, you can't use ordinary arithmetical operators on them - you have to say things like:

in other words, use method calls on the BigInteger objects for everything. yes, i imagine this might get tiresome pretty quickly, but that's the way it is.
 
Justin Porter
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok thanks, I'll look up the BigInteger class in the API. Thanks for the quick response!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic