473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how do I print 64 bit int in c++

Hi All,
I'm trying to print 64 bit int in linux and in windows with cout, can
any one give a solution?

Windows:
__int64 a;
cout<<a;

Linux:
unsigned long long b;
cout<<b;

Thanks,
Reuven.

Jul 23 '05 #1
5 5349

<re*******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
| Hi All,
| I'm trying to print 64 bit int in linux and in windows with cout, can
| any one give a solution?
|
| Windows:
| __int64 a;
| cout<<a;
|
| Linux:
| unsigned long long b;
| cout<<b;

Note sure I fully understand your question, but
use both if you have to, or find a large number
library on google:

void Print64Bit()
{
#if defined __cplusplus
#if defined __WIN32__
// *non-portable* code that suits Windows
#endif

#if defined __UNIX__
// *non-portable* code that suits Unix
#endif
#endif
}

Cheers,
Chris Val
Jul 23 '05 #2
re*******@gmail.com wrote:
Hi All,
I'm trying to print 64 bit int in linux and in windows with cout, can
any one give a solution?

Windows:
__int64 a;
cout<<a;

Linux:
unsigned long long b;
cout<<b;


get a later version of the windoze compiler.
Jul 23 '05 #3
re*******@gmail.com wrote:
Hi All,
I'm trying to print 64 bit int in linux and in windows with cout, can
any one give a solution?

Windows:
__int64 a;
cout<<a;

Linux:
unsigned long long b;
cout<<b;

Thanks,
Reuven.


Most Linux compilers support 64 bit ints.
Take a look at 'stdint.h' (usually in /usr/include).
for the implementation details. 'stdint.h' is part
of the ISO C99 standard.

I don't know if the latest MS compilers have 'stdint.h';
my old copy of Visual Studio 98 does not...
Here's one possibility:

#ifndef _MSC_VER
// not Windows (linux/unix)
#include <stdint.h>
#endif

#ifdef _MSC_VER
__int64 a; // Windows
#else
int64_t a; // not Windows
#endif

std::cout << a;

Regards,
Larry

--
Anti-spam address, change each 'X' to '.' to reply directly.
Jul 23 '05 #4
On 19 Apr 2005 01:57:59 -0700 in comp.lang.c++, re*******@gmail.com
wrote,
Hi All,
I'm trying to print 64 bit int in linux and in windows with cout, can
any one give a solution?


Step one: choose a compiler that supports it.

See:
http://groups.google.com/gr*********....earthlink.net

Jul 23 '05 #5
> Hi All,
I'm trying to print 64 bit int in linux and in windows with cout, can
any one give a solution?

Windows:
__int64 a;
cout<<a;

Linux:
unsigned long long b;
cout<<b;


Hello.

You can use some library for long number. For example:

http://sourceforge.net/projects/muntl/

Multiprecision unsigned number template library (MUNTL). The program
is intended for the organization of calculations with the big
precision for unsigned numbers. Program is very fast because do not
use any heap call (new, malloc etc.) Program is not use GMP. Program
is not limit of number length.

Sincerely yours
Basil
Jul 23 '05 #6

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

Similar topics

12
by: Michael Foord | last post by:
Here's a little oddity with 'print' being a reserved word... >>> class thing: pass >>> something = thing() >>> something.print = 3 SyntaxError: invalid syntax >>> print something.__dict__...
14
by: Marcin Ciura | last post by:
Here is a pre-PEP about print that I wrote recently. Please let me know what is the community's opinion on it. Cheers, Marcin PEP: XXX Title: Print Without Intervening Space Version:...
0
by: bearophileHUGS | last post by:
There is/was a long discussion about the replacement for print in Python 3.0 (I don't know if this discussion is finished): http://mail.python.org/pipermail/python-dev/2005-September/055968.html ...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
1
by: Steff | last post by:
I am wandering if my code is making sense... I use a lot the print function. Is it weird in this case where I have to display an array ? I thought it would be better to have the entire array in php...
3
by: James J. Besemer | last post by:
I would like to champion a proposed enhancement to Python. I describe the basic idea below, in order to gage community interest. Right now, it's only an idea, and I'm sure there's room for...
69
by: Edward K Ream | last post by:
The pros and cons of making 'print' a function in Python 3.x are well discussed at: http://mail.python.org/pipermail/python-dev/2005-September/056154.html Alas, it appears that the effect of...
2
by: Brad Pears | last post by:
I have some sample code that uses the print dialog, print preview and a print direct options. If I select print preview and then click the printer icon from that, the document prints. If I...
7
by: samslists | last post by:
Am I the only one that thinks this would be useful? :) I'd really like to be able to use python 3.0's print statement in 2.x. Is this at least being considered as an option for 2.6? It seems...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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,...
0
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...
0
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...
0
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,...

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.