Thread: Data type

  1. #1
    Banned
    Join Date
    Apr 2015
    Posts
    596

    Data type

    Hi ! for some purposes I want my program to do a matrix with size
    which is:
    size=10000000000
    which the matrix will be on size 100000*100000
    what data type should I used? it's integer but I mean long integer or what? because while ordering my program to print that value, in my command console doesn't appear anything, and tells me process finished with exit code -1073741819.
    Afterwards I tried to print instead of size=10000000000 , I tried size=60
    it printed out to my screen, any clue what's going on? and how can I deal with that big number?
    I used
    Code:
     printf("%llu", matrix[i][j]);
    and it didn't prints out!

    thanks alot
    Last edited by RyanC; 05-08-2019 at 07:22 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,158
    Try:
    Code:
    long long x = 10000000000LL;
    printf("%lld\n", x);
    If that doesn't work, state your compiler and its version.

    EDIT:
    Wait, I just saw that you started talking about matrices. The type to consider for printf is the type of an element of the matrix, it has nothing to do with the size. The size would introduce concerns about whether you're allocating on the stack etc, but that's a different story.
    Last edited by laserlight; 05-08-2019 at 07:28 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Banned
    Join Date
    Apr 2015
    Posts
    596
    Quote Originally Posted by laserlight View Post
    Try:
    Code:
    long long x = 10000000000LL;
    printf("%lld\n", x);
    If that doesn't work, state your compiler and its version.

    EDIT:
    Wait, I just saw that you started talking about matrices. The type to consider for printf is the type of an element of the matrix, it has nothing to do with the size. The size would introduce concerns about whether you're allocating on the stack etc, but that's a different story.
    I'm totally with you, but if I put size matrics smaller then it works for me fine!! but if I put size like 10000000000 then there's no output and my pc starts making some noise, and sometimes shown me a note "you've no memory for .." , it might be memory issue? if so how can I overcome on that problem? I must change PC and try on other computer?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,490
    > I'm totally with you, but if I put size matrics smaller then it works for me fine!! but if I put size like 10000000000
    Try to realise that your machine is finite, and you just can't throw in arbitrarily large numbers for an array size without consequences.

    Post the code you have for a size which works, and then ask how to make it larger.

    It also helps to know if your matrix has any special properties, like
    - it's sparse
    - it's only an upper/lower diagonal
    - it's only got booleans
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 17
    Last Post: 08-05-2018, 06:59 PM
  2. Replies: 2
    Last Post: 05-14-2011, 09:26 PM
  3. store string data as a short or other data type
    By robin2aj in forum C Programming
    Replies: 5
    Last Post: 04-07-2010, 11:02 AM
  4. data type for hex
    By cutelucks in forum C Programming
    Replies: 3
    Last Post: 04-29-2007, 07:57 PM
  5. What Data type.........
    By Nectron in forum C++ Programming
    Replies: 2
    Last Post: 07-10-2003, 06:34 AM

Tags for this Thread