Results 1 to 12 of 12

Thread: long long in MSVC++ 6

  1. #1

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237

    long long in MSVC++ 6

    What is long long's equivalent in MSVC++ 6. I have a long long in minGW (g++) and it compiles and runs correctly. I can't have a long long in VC++ so I tried long int anf int long, neight worked... any ideas?

    NOMAD

  2. #2
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    __int64 myint = 5;//64bit integer

    Note it is 2 underscores.

  3. #3

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237

    hmmm

    Where do you get __int64, is it standard or part of VC++? The underscores make it look like a C style data type. Also that seems platform dependent. What is my system was old and longs (and ints) where 16 bits, I'd only need a 32 bit int (like they are now).

    Thanks, I'll use it if I have to but is there anothrer way?

    NOMAD

  4. #4
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    __int64 is not standard, in general anything that starts with an underscore is compiler specific.
    To get a more portable 64 bit int you could use boost:
    #include <boost/cstdint.hpp>
    boost::int64_t a;//64 bits

    Also, VC6 only runs on 32 bit platforms, so a 'long long' is always __int64

  5. #5

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    So what Im hearing is there is no 64 bit int in MS version of the C++ standard. What up with dat? Why no long long, that is valid standard c++ right? Isn't double long (or is it long double)? some one explain the vision of MS in doing this?

    NOMAD

    PS: boost is an awsome library but my prof has said we are to only use standard c++.

  6. #6
    Hyperactive Member Emo's Avatar
    Join Date
    Jul 2000
    Posts
    428
    what about unsigned int? that gives you a value from 0 to 65535... wouldn't that work?

    -Emo
    -=VB6 Enterprise Edition=-
    -=VC++6Enterprise Edition=-
    «¤E³m°O²™¤»

  7. #7
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396

    Re: hmmm

    Originally posted by NOMADMAN
    Where do you get __int64, is it standard or part of VC++? The underscores make it look like a C style data type. Also that seems platform dependent. What is my system was old and longs (and ints) where 16 bits, I'd only need a 32 bit int (like they are now).

    Thanks, I'll use it if I have to but is there anothrer way?

    NOMAD
    int is already 32bit in VC6 if that is what you want.

    int is 16bit on 16bit compiler for 16bit platform.

    int is 32bit on 32bit compiler for 32bit platform.

    If you are using an old compiler(16bit) (like Turbo C++), int would be 16bit.

    Size of int is not fixed in the standard.

    If you do not believe me, do something like this

    cout<<sizeof(int)<<endl;

    if you are using VC6, it would show you 4 which means 4 bytes(32bit).

  8. #8

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    Since this thread had no simple answer I guess I could give you some background. I'm learning about policys and traits (still not sure how they work). But anyway, we made a templated function called Accumulate ( total += value ). Made to take a int but return a long then I realized long isn't big enough (they're both 32 bit). so whats 64? And I'm sorry unsigned doesn't work cause I'm using ints not unsigned. Although the same problem arrises with unsigned ints and unsigned long longs...

    I'm just curious why MS didn't allow it.

    NOMAD

  9. #9

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    Didn't see the last post (not mine smart ass)

    No the fact that int IS 32 bit is the problem, I need something bigger (like 64bit)
    I know the implementations are different thats why __int64 won't work. What if I'm on some magical 64bit system?

    Thanks, guess I'm not very clear with my speeching.

    NOMAD

  10. #10
    Fanatic Member
    Join Date
    May 2001
    Posts
    837
    I do wonder too why int and long have the same size...but in .net there are 64 bit data types.
    The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    There is no MS version of the C++ standard. C++ standard is a standard, therefore it's the same for all vendors.

    Ok, after that necessary rant here's something more concrete.

    MSVC++ was among the first compilers to offer a 64-bit data type. It was called (because it was compiler specific) __int64. The type is guaranteed to be 64 bits (8 bytes) wide, no matter what.
    The C++ standard was later extended witht the "long long" data type, which should be 64-bit too. But even in VC++7 MS still doesn't support long long. VC++8 probably does, it's supposed to be one of the most compliant compilers.

    So if you need a 64-bit integer, the boost typedef as twanvl showed it should be the best.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12

    Thread Starter
    Addicted Member NOMADMAN's Avatar
    Join Date
    Aug 2002
    Location
    Closer than you think
    Posts
    237
    Thanks you corned bee.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width