Skip to main content
GameDev.net gamedev.net
🔒 Locked

Huge integer data type in C++

Started by AndreTheGiant Nov 20, 2003 at 12:45 PM 6 replies 950+ views
Original Post
AndreTheGiant
AndreTheGiant
How difficult would it be to write some c++ code that supports doing math with huge integers? (ie integers of arbitrary lengths, like 50, 100 or even 1000 digits). I want more operations than the standard +,-,*,-. For eg, I would want exponent, log, root, mod, and others. Is this terribly hard to do? I think the boost library might have some of the functionality that I want, but I would prefer to write it myself if possible. Has anyone tried doing this? Can anyone point me to a previous thread on this topic or maybe an article somewhere? Thanks.
Fruny
Fruny
GNU MP Bignum.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
a2ps
a2ps
i think that means why having work by doing it yourself when there is already one made? and probably better that the one you would do. my advise: try to use always already made librarys.
yet, another stupid signature..
AndreTheGiant
AndreTheGiant
quote:

i think that means why having work by doing it yourself when there is already one made? and probably better that the one you would do. my advise: try to use always already made librarys.



Using that logic, why are you guys all making games? Why dont you just play the ones out there that are already made? They would probably be better than the one you would do.

The obvious answer is that I would like to learn how to do it, provided it isnt a whole lot more complicated than I think it is. I dont like using libraries for something that I could write myself, and I just wanted to know what the chances were of me being able to write something like that myself.
Fruny
Fruny
quote:
Original post by AndreTheGiant
Thanks for the link.
Does that mean that its probably too hard for me to write it myself?


Not so difficult to write a naive prototype.
Much harder to write a really usable class.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Fruny
Fruny
Using that logic, why are you guys all making games?

If you search my post history, I never said I was making games.

Why dont you just play the ones out there that are already made? They would probably be better than the one you would do.
...
I dont like using libraries for something that I could write myself


It depends on whether your goal is to write a game - in which case re-writing libraries can be seen as an unwelcome distraction and waste of time, or is to go and write libraries.

Many people here focus so much on writing yet another generic game engine that they forget to try and actually write a game.

The obvious answer is that I would like to learn how to do it, provided it isnt a whole lot more complicated than I think it is.
z
That''s a worthy goal of it own.

I just wanted to know what the chances were of me being able to write something like that myself.

It depends on how much algebra you know and how much time you are willing to invest in researching (or just plain searching ) for proper algorithms.




[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
LousyPhreak
LousyPhreak
quote:

Using that logic, why are you guys all making games? Why dont you just play the ones out there that are already made? They would probably be better than the one you would do.


not quite right. using that logic actually means that i would/should stop making games if every game that i could imagine would already be out there having every feature i like...

quote:

The obvious answer is that I would like to learn how to do it, provided it isnt a whole lot more complicated than I think it is.


depends on your skills as Fruny pointed out
quote:

I dont like using libraries for something that I could write myself


for many things i agree with you but sometimes it is easier to just use the wheel as it has been developed over the past instead of inventing your own just to find that the already made one just rolls that much smoother .
on the other hand is totally different if you want to do it for education/improving in which case like this tast could be quite interesting.

but this are just some random rants from someone who doesn''t know any better ...
http://mitglied.lycos.de/lousyphreak/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.