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
Printable View
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
__int64 myint = 5;//64bit integer
Note it is 2 underscores.
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
__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
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++.
what about unsigned int? that gives you a value from 0 to 65535... wouldn't that work?
-Emo
int is already 32bit in VC6 if that is what you want.Quote:
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 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).
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
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
I do wonder too why int and long have the same size...but in .net there are 64 bit data types.
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.
Thanks you corned bee.