• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks, I'll look up the BigInteger class in the API. Thanks for the quick response!
reply
    Bookmark Topic Watch Topic
  • New Topic