1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Computer programing - making new data types for integers java/c

  1. Jul 14, 2010 #1
    How would I make a new data type that would hold larger numbers than ones that we can currently use?

    for example I need a data type that can handle calculations from large factorials
    e.g
    200!, = 200*199*198*197 ...................
    it's a really large number and can't be saved in ints/doubles/longs ect...
    so i need to make a new data type,

    how would I do this?

    I know both java and C, but would prefer it if the help was done in java

    thanks
     
  2. jcsd
  3. Jul 14, 2010 #2
    google: arbitrary precision arithmetic

    plus java has a BigInteger class already.
     
  4. Jul 14, 2010 #3
    thanks,

    another note, i'm doing an assignment
    and have been told that i'm not allowed to use biginteger
     
  5. Jul 14, 2010 #4

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    You already know how -- you do it with pen and paper all the time.

    However, base 65536 or base 4294967296 is probably more convenient than base 10.


    qbert gave you a buzzword for searching. Another one is "multi-precision arithmetic".
     
  6. Jul 17, 2010 #5
    you will need to use the bit operators( | &) and keep track of the bit pushed off the the lower words and add it to the higher words
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook