Thread: is there an infinitely large integer type?

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    24

    Question is there an infinitely large integer type?

    Is there an infinitely large integer file. I am writing a program that processes large files, and I need to make an infinitewly large array. How do I do this?

    thanks
    Dmitry Kashlev

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I need to make an infinitewly large array
    You can't do this because of memory constraints.

    >I am writing a program that processes large files
    I doubt that you have to process the entire file in memory all at once. Read a block of the file and process it, then save that block to disk and read another. Lather, rinse, repeat until the file has been completely processed.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    24

    Exclamation

    your idea is fine, but i need infinitely large integer because I am calculating the total number of nonnumerical values in each column of data (a 100MB file), and then replace those nonnumerical values with numbers in the order of their sequence in the array.
    Dmitry Kashlev

  4. #4
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301
    read it in in blocks, and use multiple integers. unsigned long long's work pretty good ... the range has to be in the trillions at least.

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    try doubles
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Registered User
    Join Date
    Feb 2002
    Posts
    114
    max for unsigned long long is 18446744073709551615... i hope you realise how large that number is... hehe...

  7. #7
    Registered User
    Join Date
    Aug 2002
    Posts
    24
    what about signed long? How I initialize only positive longs?
    Dmitry Kashlev

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    66
    i need infinitely large integer
    What you're talking about is arbitrary precision arithmetic. You define your own number using either linked lists or an array so that you can have a huge precision in your calculation or you can use enormous numbers. Like if you're using an array, you can have a portable number up to 32,767 digits. But I imagine that for your problem a double would work fine.
    How I initialize only positive longs?
    Simple, just declare it as unsigned.

    unsigned long num;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. No Match For Operator+ ???????
    By Paul22000 in forum C++ Programming
    Replies: 24
    Last Post: 05-14-2008, 10:53 AM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. Newbies question about the integer type
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 10-17-2001, 08:09 PM