|
-
Mar 6th, 2003, 02:46 AM
#1
Thread Starter
Addicted Member
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
-
Mar 6th, 2003, 05:28 AM
#2
Hyperactive Member
__int64 myint = 5;//64bit integer
Note it is 2 underscores.
-
Mar 6th, 2003, 12:35 PM
#3
Thread Starter
Addicted Member
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
-
Mar 6th, 2003, 04:47 PM
#4
__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
-
Mar 6th, 2003, 05:29 PM
#5
Thread Starter
Addicted Member
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++.
-
Mar 6th, 2003, 08:01 PM
#6
Hyperactive Member
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²™¤»
-
Mar 6th, 2003, 09:18 PM
#7
Hyperactive Member
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).
-
Mar 6th, 2003, 11:17 PM
#8
Thread Starter
Addicted Member
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
-
Mar 6th, 2003, 11:20 PM
#9
Thread Starter
Addicted Member
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
-
Mar 7th, 2003, 08:15 AM
#10
Fanatic Member
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.
-
Mar 7th, 2003, 03:30 PM
#11
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.
-
Mar 7th, 2003, 06:58 PM
#12
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|