how do I print 64 bit int in c++

R

reuven.sa

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.
 
C

Chris \( Val \)

| 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
 
G

Gianni Mariani

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.
 
L

Larry I Smith

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
 
B

Basil

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,158
Latest member
Vinay_Kumar Nevatia
Top