This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Justin Porter
Ranch Hand
Posts: 34
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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!
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic