Using very big numbers, long isn't enough

This is a discussion on Using very big numbers, long isn't enough within the C++ Programming forums, part of the General Programming Boards category; I am trying to do calculations with very big numbers. In my calculation, for instance, the faculty of 64 is ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    367

    Using very big numbers, long isn't enough

    I am trying to do calculations with very big numbers. In my calculation, for instance, the faculty of 64 is to be included in a function, and that is a very big number: 1,2688693218588416410343338933516e+89.

    My program doesn't seem to work properly after around the faculty of 30. I first used int in my functions but then I tried to replace them with long. This didn't help, so I'm suspecting that using long still isn't enough. Is there a way I can handle even bigger numbers? Is there an absolute limit to the size of numbers a program can handle?

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    >Is there an absolute limit to the size of numbers a program can handle?

    with standard c/c++ data types - yes

    try this thread

    Division Algorithm
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    367
    Thanks for the thread misplaced. I think it is a bit too complicated for me as I am more of a novice. I tried to use the code suggested by SangDrax but it didn't seem to compile correctly. I don't have the time to dig through all of this theory of how to write the code that handles big numbers for now. I am just in the need for handling big numbers which in itself is part of a function which is only a small part of a big project that I want to accomplish. If I went through it, perhaps I would learn more, but it would get me more away from my main target and I don't want that. I know I should also have searched for similar posts myself but I thought that too would take too much time. I am simply in the need of clear answers, if there are any.

    So, can anyone suggest me the most simple way to handle very big (perhaps even infinitely big) numbers?

    - Thanks, Zewu

  4. #4
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154
    lol, if your dealing with numbers like that, then buy one of those mainframes that can work out numbers like pi to 6th trillion decimal place or something, what are you working out that is that big any way?

  5. #5
    Registered User
    Join Date
    Dec 2001
    Posts
    367
    Seriously, that number I posted can be handled in Windows' own calculator so I think handling it on a computer shouldn't be too difficult.

    Sorry for my impatience, I have now searched a few threads and come acroos something called GPU. I have read their introduction of it and I understand it is used for calculating big numbers. I don't know how to use it though =/
    Last edited by Zewu; 03-26-2005 at 04:42 PM.

  6. #6
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    The double datatype may be of use to you, as it stores an exponent. This means that not all digits can be accurately kept, but for the purposes of calculation it should work OK for large numbers.

    If you need something that handles larger numbers, maybe Lucky's code can help you:
    "Unlimited" Length Floating Point Numbers

    Otherwise, there's a large number library somewhere, maybe that was GPU.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  7. #7
    People Love Me
    Join Date
    Jan 2003
    Posts
    412
    - Scientific notation is good. How do you think Mr. Avagrado writes his number, hmm?
    - __int64 is good. It can hold over 18 quintillion values.
    - String parsed into an int is good.

  8. #8
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Perhaps you meant GMP?
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    367
    Yes, GMP was it. Unfortunately, I am unsure of how to use it.

  10. #10
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    There's plenty of documentation on the site.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reset values
    By dpp in forum C++ Programming
    Replies: 30
    Last Post: 01-27-2009, 08:06 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Sorting Algorithms with Time
    By silicon in forum C++ Programming
    Replies: 3
    Last Post: 05-03-2005, 12:27 PM
  4. Peculiar Problem with Printf
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-02-2002, 01:34 AM
  5. Peculiar Problem with Printf
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 07-02-2002, 01:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21