473,748 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does your favorite C++ compiler support 64-bit integer types?

Please skip to the last paragraph if you are in a hurry.

Some of the integer variables in my application will need to hold values
bigger than 2^32-1.

Others won't need to be that big. Time and space efficiencies on
run-of-the-mill (read: 32 bit) microcomputers are important.

I want to use some layer of abstraction comparable to C99's stdint.h so
that my variable declarations specify the number of bits.

My app is to run on general-purpose hardware on Linux, Mac, BSD, and
Windows.

I am more interested in practical portability than in ISO standards.
Also it seems to be irrelevant whether the 64-bit type is long or long long.

Which C++ compilers do and which do not have 64-bit integer types? And
do they have something like stdint.h?

Jul 22 '05 #1
40 4251
On Tue, 13 Apr 2004 21:19:04 GMT in comp.lang.c++, Matt
<ma**@themattfe lla.zzzz.com> wrote,
Which C++ compilers do and which do not have 64-bit integer types? And
do they have something like stdint.h?


Digital Mars C++ http://www.digitalmars.com
has "long long" and stdint.h.

Jul 22 '05 #2
"Matt" <ma**@themattfe lla.zzzz.com> wrote in message
news:cP******** ********@news02 .roc.ny
Please skip to the last paragraph if you are in a hurry.

Some of the integer variables in my application will need to hold
values bigger than 2^32-1.

Others won't need to be that big. Time and space efficiencies on
run-of-the-mill (read: 32 bit) microcomputers are important.

I want to use some layer of abstraction comparable to C99's stdint.h
so that my variable declarations specify the number of bits.

My app is to run on general-purpose hardware on Linux, Mac, BSD, and
Windows.

I am more interested in practical portability than in ISO standards.
Also it seems to be irrelevant whether the 64-bit type is long or
long long.

Which C++ compilers do and which do not have 64-bit integer types?
And
do they have something like stdint.h?


Microsofts has a 64 bit data type, though I think it is less efficient than
the 32 bit integer type. The various types (besides the usual int etc.) are
listed here.

http://msdn.microsoft.com/library/de...data_types.asp
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #3
David Harmon wrote:
On Tue, 13 Apr 2004 21:19:04 GMT in comp.lang.c++, Matt
<ma**@themattfe lla.zzzz.com> wrote,
Which C++ compilers do and which do not have 64-bit integer types? And
do they have something like stdint.h?

Digital Mars C++ http://www.digitalmars.com
has "long long" and stdint.h.


And its long long is 64 bits?

Jul 22 '05 #4
"Matt" <ma**@themattfe lla.zzzz.com> wrote in message
news:cP******** ********@news02 .roc.ny...
Please skip to the last paragraph if you are in a hurry.

Some of the integer variables in my application will need to hold values
bigger than 2^32-1.

Others won't need to be that big. Time and space efficiencies on
run-of-the-mill (read: 32 bit) microcomputers are important.

I want to use some layer of abstraction comparable to C99's stdint.h so
that my variable declarations specify the number of bits.

You can easily define your own class. I also assume that there must be some
third party free library out there provoding an 64-bit type.

Or you can use a system-specific type like __int64 in .NET.

My app is to run on general-purpose hardware on Linux, Mac, BSD, and
Windows.

I am more interested in practical portability than in ISO standards.
Also it seems to be irrelevant whether the 64-bit type is long or long long.
There isn't long long in standard C++. Portability can be maintained by
using a typedef for built in system-specific types. For example you could
do:
typedef __int 64 Int64

// ...

and change the typedef when you move to another system. The general rule is
"isolate system dependencies in a small portion of the code". You can create
a header file called
system_dependen cies.h or something.


Which C++ compilers do and which do not have 64-bit integer types? And
do they have something like stdint.h?

How many compilers exist out there? How many versions of them? The question
is meaningless. You can basically tell us what OS you are using. For Windows
a nice free port of GCC supporting Win32 API is mingw:

http://www.mingw.org/

If you want it integrated with an IDE you can download Dev-C++:
http://www.bloodshed.net/devcpp.html


Ioannis Vranos

Jul 22 '05 #5
In the Visual Studio 2005 tech preview Microsoft is giving out,
long long is supported and is the same as __int64.

Jul 22 '05 #6
On Tue, 13 Apr 2004 22:07:48 GMT in comp.lang.c++, Matt
<ma**@themattfe lla.zzzz.com> wrote,
David Harmon wrote:
On Tue, 13 Apr 2004 21:19:04 GMT in comp.lang.c++, Matt
<ma**@themattfe lla.zzzz.com> wrote,
Which C++ compilers do and which do not have 64-bit integer types? And
do they have something like stdint.h?

Digital Mars C++ http://www.digitalmars.com
has "long long" and stdint.h.


And its long long is 64 bits?


Yes. I thought I implied that. It would certainly violate expectations
if it was anything less.

Using free command line DMC++ with accompanying stlport library.
Program:

#include <iostream>
int main()
{
int j = 0;
long long int i = 0;
do {
i = (i << 1) + 1;
++j;
std::cout << j << " " << i << '\n';
} while (i > 0);
}

Output:

1 1
2 3
3 7
4 15
5 31
6 63
7 127
8 255
9 511
10 1023
11 2047
12 4095
13 8191
14 16383
15 32767
16 65535
17 131071
18 262143
19 524287
20 1048575
21 2097151
22 4194303
23 8388607
24 16777215
25 33554431
26 67108863
27 134217727
28 268435455
29 536870911
30 1073741823
31 2147483647
32 4294967295
33 8589934591
34 17179869183
35 34359738367
36 68719476735
37 137438953471
38 274877906943
39 549755813887
40 1099511627775
41 2199023255551
42 4398046511103
43 8796093022207
44 17592186044415
45 35184372088831
46 70368744177663
47 140737488355327
48 281474976710655
49 562949953421311
50 112589990684262 3
51 225179981368524 7
52 450359962737049 5
53 900719925474099 1
54 180143985094819 83
55 360287970189639 67
56 720575940379279 35
57 144115188075855 871
58 288230376151711 743
59 576460752303423 487
60 115292150460684 6975
61 230584300921369 3951
62 461168601842738 7903
63 922337203685477 5807
64 -1

Jul 22 '05 #7
Here is a brain teaser for anyone who might be interested.
The following numbers (in the second column) all end with the digit
1, 3, 5, or 7. It's obvious why they are all odd. Why can the last
digit never be 9, even if you extended the sequence?
On Tue, 13 Apr 2004 22:57:45 GMT in comp.lang.c++, David Harmon
<so****@netcom. com> wrote,
Program:

#include <iostream>
int main()
{
int j = 0;
long long int i = 0;
do {
i = (i << 1) + 1;
++j;
std::cout << j << " " << i << '\n';
} while (i > 0);
}

Output:

1 1
2 3
3 7
4 15
5 31
6 63
7 127
8 255
9 511
10 1023
11 2047
12 4095
13 8191
14 16383
15 32767
16 65535
17 131071
18 262143
19 524287
20 1048575
21 2097151
22 4194303
23 8388607
24 16777215
25 33554431
26 67108863
27 134217727
28 268435455
29 536870911
30 1073741823
31 2147483647
32 4294967295
33 8589934591
34 17179869183
35 34359738367
36 68719476735
37 137438953471
38 274877906943
39 549755813887
40 1099511627775
41 2199023255551
42 4398046511103
43 8796093022207
44 17592186044415
45 35184372088831
46 70368744177663
47 140737488355327
48 281474976710655
49 562949953421311
50 112589990684262 3
51 225179981368524 7
52 450359962737049 5
53 900719925474099 1
54 180143985094819 83
55 360287970189639 67
56 720575940379279 35
57 144115188075855 871
58 288230376151711 743
59 576460752303423 487
60 115292150460684 6975
61 230584300921369 3951
62 461168601842738 7903
63 922337203685477 5807
64 -1


Jul 22 '05 #8
"David Harmon" <so****@netcom. com> wrote in message
news:40******** ********@news.w est.earthlink.n et
Here is a brain teaser for anyone who might be interested.
The following numbers (in the second column) all end with the digit
1, 3, 5, or 7. It's obvious why they are all odd. Why can the last
digit never be 9, even if you extended the sequence?


i = (i << 1) + 1;

translates to

i = i*2 +1;

This is a first order difference equation with solution (given the initial
condition)

i_n = 2^n - 1

where i_n is the nth term in the sequence and ^ denotes exponent.
(Alternatively, you are forming each successive number by left-shifting and
adding 1, which means that you have a binary number consisting solely of 1s.
Such numbers are of the form 2^n - 1.)

For a number to end in 9, we would need:

2^n - 1 == K*10 + 9

for some integers n and K. Adding 1 to both sides

2^n == K*10 + 10

or

2^n == (K+1)*10

Dividing both sides by 2:

2^(n-1) == (K+1)*5

We see that the left hand side has 2 as its only prime factor, whereas the
right hand side has 5 as a prime factor. By the unique prime factorisation
theorem, this is impossible if the left and right hand sides are equal. This
shows the equality is impossible. QED.
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #9
David Harmon wrote:
Here is a brain teaser for anyone who might be interested.
The following numbers (in the second column) all end with the digit
1, 3, 5, or 7. It's obvious why they are all odd. Why can the last
digit never be 9, even if you extended the sequence?


It would imply that some power of two is divisible by five.

Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2823
by: Randy Given | last post by:
What is your favorite Java development environment? What others have you tried? What are some pros and cons of each? Thanks!
1
1980
by: ninth | last post by:
in aix , when i compiler the code of db2 sample in 64 mode ,a error return. xlc -o db2mon db2mon.c tilapi.o -q64 -I/db2home/hnbas/sqllib/include -L/db2home/hnbas/sqllib/lib - ldb2 ld: 0711-317 ERROR: Undefined symbol: .sqleatin_api ld: 0711-317 ERROR: Undefined symbol: .sqlaintp_api ld: 0711-317 ERROR: Undefined symbol: .sqlmonsz ld: 0711-317 ERROR: Undefined symbol: .sqlmonss ld: 0711-317 ERROR: Undefined symbol: .sqlmrset ld:...
8
1604
by: ±èµ¿±Õ | last post by:
#include"stdio.h" main() { int a = 128 * 128 * 128 * 128 * 128 * 128 * 128 * 128 ; int a1 = 256 * 256 * 256 * 256; char b = 256 * 256 * 256 * 256; long c = 256 * 256 * 256 * 256; float d = 512 * 512; double e = 64 * 64 * 64 * 64 * 64 * 64 * 64 * 64 * 64 * 64 * 64 * 64 * 64 *
9
2295
by: JTrigger | last post by:
When I compile my project using the IDE on a development machine it works just fine. When I compile it on the server using csc.exe, I get the following error when I try to bring it up in the web browser. What is the issue? Thanks, Jim Server Error in '/psnRequest' Application. ----------------------------------------------------------------------------
48
4266
by: Jimmy | last post by:
thanks to everyone that helped, unfortunately the code samples people gave me don't work. here is what i have so far: <% Dim oConn, oRS, randNum Randomize() randNum = (CInt(1000 * Rnd) + 1) * -1 Set oConn=Server.CreateObject("ADODB.Connection") Set oRS=Server.CreateObject("ADODB.recordset") oConn.Provider="Microsoft.Jet.OLEDB.4.0" oConn.Open Server.MapPath("temp.mdb")
7
6648
by: Mark Carrington | last post by:
I'm developing a web app in .NET 2 using C#, and occasionally see this error, apparently something to do with the theme used on the site: Compiler Error Message: The compiler failed with error code 1. Clicking the "Show Detailed Compiler Output" link on the error page shows a large command line that looks like it's using the vbc compiler to build the auto-generated theme code, but doesn't display any useful error messages. Executing...
6
2430
by: Anastasios Hatzis | last post by:
Hello, I'm working on the light-weight MDA tool pyswarm, http://pyswarm.sourceforge.net/ (it is about a code-generator for Python/PostgreSQL-based software. I plan to add support of UML CASE tools other than the one supported currently. I would like to learn which UML tools you use (if any), preferrably if it comes to modeling a Python application. So I'm asking you to tell me the name of your favorite UML CASE tool(s).
5
18472
by: =?Utf-8?B?TWFydHluIEZld3RyZWxs?= | last post by:
From the amount of articles about this one I’m sure this gets asked a lot, but I haven’t yet found a succinct article which explains what is required in its entirety. I work using Visual Studio 2005 SP1 mainly in ASP.Net using VB.Net 2.0. I have an application which runs without error on my development server so I believe that the underlying code is correct. Most of my applications including this one runs on a shared server (Win
244
9574
by: Ajinkya | last post by:
Can anyone suggest me a good compiler for(c/cpp) for windows? I tried dev cpp but its debugging facility is very poor.
11
7877
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG' does not exist drop table log_errors_tab;
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.