Jump to content

Storing extremely large numbers

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
is there any way to store extremely large numbers and then perform some mathematics on it? for example a 15 digit number's factorial? unsigned long int stores upto like 10^10 , and I don't want to make my own class for it...

#2
so1i

so1i

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 312 posts
Check out GMP. I think that's probably the most common lib for arbitrary precision arithmetic! (I don't know of any others tbh).

Hope this helps. :)

#3
ahmed

ahmed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 304 posts
thanks but i don't want to use any library , so please if there's a solution to that do help o_O

#4
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,298 posts
If you don't want to use a library, it's probably a need to do it on your own yes...
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Your options:
1) use a third party library such as GMP
2) write your own.

Personally, I would recommend option 1 if this is not for a class, since there are a lot of tedious details involved that are easy to screw up, and you aren't likely to write a highly optimized library on your first 10 tries.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog