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

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
4 replies · 3K views
vorcil
Messages
395
Reaction score
0
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
 
Physics news on Phys.org
google: arbitrary precision arithmetic

plus java has a BigInteger class already.
 
thanks,

another note, I'm doing an assignment
and have been told that I'm not allowed to use biginteger
 
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".
 
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