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

Click For Summary

Discussion Overview

The discussion revolves around creating a new data type in Java or C that can handle very large numbers, specifically for calculations involving large factorials, such as 200!. Participants explore methods for implementing arbitrary precision arithmetic without using existing classes like BigInteger in Java.

Discussion Character

  • Exploratory
  • Technical explanation
  • Homework-related

Main Points Raised

  • One participant asks how to create a new data type for larger numbers than those supported by standard types like int, double, or long.
  • Another participant suggests searching for "arbitrary precision arithmetic" and mentions the existence of Java's BigInteger class.
  • A different participant notes that they cannot use BigInteger due to assignment restrictions.
  • One reply proposes using base 65536 or base 4294967296 for convenience in calculations, indicating a method of handling large numbers manually.
  • Another participant mentions the need to use bit operators and to track bits that overflow from lower to higher words in the proposed data type.

Areas of Agreement / Disagreement

Participants express different approaches to the problem, with no consensus on a single method for creating the new data type. The discussion includes both suggestions for existing solutions and original methods, indicating multiple competing views.

Contextual Notes

Participants have not resolved the specifics of the implementation, and there are limitations regarding the use of existing libraries like BigInteger. The discussion also lacks detailed mathematical steps for the proposed methods.

Who May Find This Useful

This discussion may be useful for students or programmers interested in implementing custom data types for large number calculations, particularly in the context of assignments or projects that restrict the use of standard libraries.

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
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
7K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K