By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

unsigned int support

P: n/a
faz
Dear all,

May i know the data type which can support FFFF FFFF FFFF
FFFF(18,446,744,073,709,551,615).I have declared a variable using
unsigned integer type which is supporting upto FFFF
FFFF(4,294,967,295).pls suggest me..

Thanks in advance,
faz

Aug 7 '07 #1
Share this Question
Share on Google+
12 Replies


P: n/a
On Aug 7, 9:01 am, faz <fazulu.v...@gmail.comwrote:
Dear all,

May i know the data type which can support FFFF FFFF FFFF
FFFF(18,446,744,073,709,551,615).I have declared a variable using
unsigned integer type which is supporting upto FFFF
FFFF(4,294,967,295).pls suggest me..

Thanks in advance,
faz
Sizes of datatypes and also the range of the values that they can
represent are implementation defined. The macros INT_MAX and UINT_MAX
defined in <climitswill let you know the maximum value an integral
type defined by your compiler.
-N

Aug 7 '07 #2

P: n/a
On Aug 7, 7:10 am, "Alf P. Steinbach" <al...@start.nowrote:
No, "long long" i's not yet part of the standard,
That depends which standard: it's in C99, in the current draft
C++ standard, and in every current C++ compiler I know of.
Unless you explicitly have to deal with older compilers (e.g.
VC++ 6.0), you can pretty much count on it.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 7 '07 #3

P: n/a
Alf P. Steinbach wrote:
* James Kanze:
>On Aug 7, 7:10 am, "Alf P. Steinbach" <al...@start.nowrote:
>>No, "long long" i's not yet part of the standard,

That depends which standard: it's in C99, in the current draft
C++ standard, and in every current C++ compiler I know of.
Unless you explicitly have to deal with older compilers (e.g.
VC++ 6.0), you can pretty much count on it.

The standard for this group is the current C++ standard.

There's no "long long" in the standard.
But it has become ubiquitous and it is easy to test for.

--
Ian Collins.
Aug 7 '07 #4

P: n/a
Alf P. Steinbach wrote:
* Ian Collins:
>Alf P. Steinbach wrote:
>>* James Kanze:
On Aug 7, 7:10 am, "Alf P. Steinbach" <al...@start.nowrote:

No, "long long" i's not yet part of the standard,
That depends which standard: it's in C99, in the current draft
C++ standard, and in every current C++ compiler I know of.
Unless you explicitly have to deal with older compilers (e.g.
VC++ 6.0), you can pretty much count on it.
The standard for this group is the current C++ standard.

There's no "long long" in the standard.
But it has become ubiquitous and it is easy to test for.

T:\cat <bah.cpp
int main() { long long bah; }

T:\gnuc --version
g++ (GCC) 3.4.4 (mingw special)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
T:\gnuc bah.cpp
bah.cpp: In function `int main()':
bah.cpp:1: error: ISO C++ does not support `long long'
bah.cpp:1: warning: unused variable 'bah'
So what ever "gnuc" is, it is invoking g++ in pedantic mode. You have
the choice of being pedantic, or pragmatic. If you had to do 64 bit
math, which would you prefer?

By easy to test for, I was thinking of something along the lines of

#include <limits.h>

int main() {
#if !defined ULLONG_MAX
# SomeBigIntClass bah;
#else
long long bah;
#endif
}

--
Ian Collins.
Aug 7 '07 #5

P: n/a
faz


I have tried this using VC++ 1998(older version)

int main()
{
long long bas;
return 0;

}
D:\Program Files\Microsoft Visual Studio\my projects\link list
\long.cpp(4) : error C2632: 'long' followed by 'long' is illegal
Error executing cl.exe.

long.obj - 1 error(s), 0 warning(s)

Not supported...I guess my compiler is 32-bit....Which compiler
support this??

regards,
faz

Aug 7 '07 #6

P: n/a
faz a écrit :
>
I have tried this using VC++ 1998(older version)

int main()
{
long long bas;
return 0;

}
D:\Program Files\Microsoft Visual Studio\my projects\link list
\long.cpp(4) : error C2632: 'long' followed by 'long' is illegal
Error executing cl.exe.

long.obj - 1 error(s), 0 warning(s)

Not supported...I guess my compiler is 32-bit....Which compiler
support this??
long long was introduced in C99. It is not really a surprise a compiler
didn't know about it in 98.

Michael
Aug 7 '07 #7

P: n/a
On 2007-08-07 00:14:05 -0400, Neelesh Bodas <ne***********@gmail.comsaid:
On Aug 7, 9:01 am, faz <fazulu.v...@gmail.comwrote:
>Dear all,

May i know the data type which can support FFFF FFFF FFFF
FFFF(18,446,744,073,709,551,615).I have declared a variable using
unsigned integer type which is supporting upto FFFF
FFFF(4,294,967,295).pls suggest me..

Thanks in advance,
faz

Sizes of datatypes and also the range of the values that they can
represent are implementation defined. The macros INT_MAX and UINT_MAX
defined in <climitswill let you know the maximum value an integral
type defined by your compiler.
Those macros give you the maximum values for int and unsigned int.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Aug 7 '07 #8

P: n/a
joe
On Aug 7, 6:45 am, faz <fazulu.v...@gmail.comwrote:
I have tried this using VC++ 1998(older version)

int main()
{
long long bas;
return 0;

}

D:\Program Files\Microsoft Visual Studio\my projects\link list
\long.cpp(4) : error C2632: 'long' followed by 'long' is illegal
Error executing cl.exe.

long.obj - 1 error(s), 0 warning(s)

Not supported...I guess my compiler is 32-bit....Which compiler
support this??

regards,
faz
As was briefly mentioned earlier, for earlier versions of VC, you want
the __int64 or unsigned __int64 type rather than long long. The more
recent versions of VC have added the long long type in anticipation of
the draft C++ standard.

joe

Aug 7 '07 #9

P: n/a
On Aug 7, 1:19 pm, Michael DOUBEZ <michael.dou...@free.frwrote:
faz a écrit :
I have tried this using VC++ 1998(older version)
int main()
{
long long bas;
return 0;
}
D:\Program Files\Microsoft Visual Studio\my projects\link list
\long.cpp(4) : error C2632: 'long' followed by 'long' is illegal
Error executing cl.exe.
long.obj - 1 error(s), 0 warning(s)
Not supported...I guess my compiler is 32-bit....Which compiler
support this??
long long was introduced in C99. It is not really a surprise a compiler
didn't know about it in 98.
Actually, it was introduced in one of the Unix standards long
before that. From what I understand, the ISO C committee didn't
particularly like it; what do you write in ten years time, for
128 bit ints: long long long? But even at the time the 1999
standard was being finalized (1997 or before), it was too
ubiquious to be ignored.

In the case of Visual Studios, of course, the Unix standards
aren't applicable, and VC++ actually did something more
intelligent, defining a type _int64 (which extends in a rather
obvious fashion, *and* is sort of in the implementation
namespace, although as a keyword, it really needs two
underscores). Also, compilers have a certain lead time as well,
and it wasn't at all clear that those opposing long long in C99
wouldn't have their way until fairly late in the standardization
process, so all Microsoft can be accused of here is not
respecting the Unix standards.

Once C formally adopted it, of course, it was fairly obvious
that C++ would follow suite (as it has). I think it safe to say
that any C++ compiler less than three or four years old should
support it. (I still use GB_longlong and GB_ulonglong, though.
Types defined in a system dependant header. Just in case I run
into an older compiler.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 7 '07 #10

P: n/a
On Aug 7, 11:08 am, "Alf P. Steinbach" <al...@start.nowrote:
* James Kanze:
On Aug 7, 7:10 am, "Alf P. Steinbach" <al...@start.nowrote:
No, "long long" i's not yet part of the standard,
That depends which standard: it's in C99, in the current draft
C++ standard, and in every current C++ compiler I know of.
Unless you explicitly have to deal with older compilers (e.g.
VC++ 6.0), you can pretty much count on it.
The standard for this group is the current C++ standard.
The standard for this group is "portable C++", whatever that
means. Depending on your exact portability requirements, it
would be stupid not to use it. Or to use it, depending, as I
said, on your portability requirements.
There's no "long long" in the standard.
Depends on which standard.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 7 '07 #11

P: n/a
On Aug 7, 1:23 pm, Pete Becker <p...@versatilecoding.comwrote:
On 2007-08-07 00:14:05 -0400, Neelesh Bodas <neelesh.bo...@gmail.comsaid:
On Aug 7, 9:01 am, faz <fazulu.v...@gmail.comwrote:
Dear all,
May i know the data type which can support FFFF FFFF FFFF
FFFF(18,446,744,073,709,551,615).I have declared a variable using
unsigned integer type which is supporting upto FFFF
FFFF(4,294,967,295).pls suggest me..
Sizes of datatypes and also the range of the values that they can
represent are implementation defined. The macros INT_MAX and UINT_MAX
defined in <climitswill let you know the maximum value an integral
type defined by your compiler.
Those macros give you the maximum values for int and unsigned int.
It might also be worth pointing out that you can easily test for
long long by means of such macros:

#include <limits.h>
#ifdef LLONG_MAX
typedef long long MyLongLong ;
#else
???
#endif

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 7 '07 #12

P: n/a

Jim Langston <ta*******@rocketmail.comwrote in message...
"Ian Collins" <ia******@hotmail.comwrote in message...
>
Or rather the OP needs (unsigned) long long, which often does not
require a 64 bit compiler (whatever that might be).

I don't think that unsigned long long is guaranteed to be 64 bit in all
implentations, is it?
Soon! GNU's had it for a while. <G>

[ GCC(MinGW)3.3.1, win98se, iP4]
// #include <limits>

std::cout <<" LL digits ="
<<(std::numeric_limits<long long>::digits)<<std::endl;
// LL digits =63

std::cout <<" ULL digits ="
<<(std::numeric_limits<unsigned long long>::digits)<<std::endl;
// ULL digits =64

std::cout<<" LD digits ="
<<(std::numeric_limits<long double>::digits)<<std::endl;
// LD digits =64

--
Bob R
POVrookie
Aug 7 '07 #13

This discussion thread is closed

Replies have been disabled for this discussion.