My question is quite simple. But it is so simple that I can't find how
to do it.
How to convert an unsigned __int64 value to a String?
Thanks taking the time to read.
Stéphane Lambert
sla...@hotmail.com
In what representation? Hex? Decimal?
Have you looked at Format()? How about IntToHex()?
Bill
One solution is to use the function 'ui64toa()'
Andrue Cope
[Bicester, UK]
If '__int64' is streamable you can use the standard
C++ solution:
template< typename T >
inline std::string convertToString(T o)
{
std::ostringstream oss;
oss << o;
return oss.str();
}
> Stéphane Lambert
Schobi
--
Spam...@gmx.de is never read
I'm hschober at gmx dot de
P.S.: Ich suche einen Job in Berlin.
Well 'ui64toa' doesn't exist. I did not found it in the online help and
if I even try to use it, the compiler complain with this following
message: "Call to undefined function 'ui64toa'".
Do you know where I can find this function?
Thanks,
Stephane.
Here is what I use...
__int64 plynodecount[32];
__int64 nodecount;
AnsiString msg=Format("%2.0n ",ARRAYOFCONST(((double)(depth-(i-1)))))+
Format("Plynodes=%15.0n ",ARRAYOFCONST(((double)(plynodecount[i]))))+
Format("BF=%5.1n",ARRAYOFCONST(((double)(branchfactor))));
Larry Griffiths
Adams Business Forms Inc.
"Stephane Lambert" <web...@sympatico.ca> wrote in message
news:3B0417CD...@sympatico.ca...
In fact I want to convert an unsigned __int64 value to a String value
represented in decimal like "0123456789876543210".
So, I tried the Format() function and used it as explain in the online
help but it doesn't worked.
Writing one these following line of code:
Format("%d", OPENARRAY(TVarRec, (uiResult))));
or
Format("%d", ARRAYOFCONST((uiResult)));
The compiler gives me this next error message:
[C++Error] Unit1.cpp(39): Could not find a match for
'System::OpenArray<System::TVarRec>::OpenArray(unsigned __int64)'.
If there's something wrong in those lines, I just can't find what it is.
Thanks,
Stephane.
After implemented your piece of code in my ".h" file the only problem
left is how to use it? Since all this stuff is pretty new to me I'd try
something like this...
String sResult = convertToString(uiResult);
...but this is obviously not the right way to use it because I get the
following compiler error:
[C++Error] Unit1.cpp(43): Cannot convert
'std::basic_string<char,std::char_traits<char>,std::allocator<char> >'
to 'System::AnsiString'.
So, sorry for my ignorance (I'm still in the learning stage of this big
universe of the c/c++ language) but can you give me an example on how to
use the convertToString() function?
Thanks,
Stephane.
Sorry. It's _ui64toa() and is defined in math.h (for BCB5 at any
rate).
Andrue Cope
[Bicester, UK]
Some questions about the piece of code you posted.
1. What type are 'depth' and 'branchfactor'?
2. Do I need to initialize those two precedent variables to some value?
3. Since a 'i' variable is used, I supposed there's some kind of loop.
So is it a 'for' or 'while' loop?
4. What exactly mean the '%n.In' and '%n.On'? I couldn't found anything
in the online help about this.
5. Does the 'plynodecount[32]' is supposed to contain the '__int64'
value that I want to convert to string?
Thanks,
Stephane.
or:
String sResult = convertToString(uiResult).c_str();
HTH
Ted
R.E.Byers
ted....@sympatico.ca
Try this:
String MyString;
__int64 myInteger;
myInteger =234987534;
MyString = String().sprintf("%Ld", myInteger);
I believe %Lu will do it for unsigned __int64.
HTH,
Micha.
As the namespace name suggests, 'std::string' is part
of the C++ Standard Library. (That's why it works so
good with 'std::stringstream.)
Contrary, 'String' is Borland's invention to resemble
Delphi's string class. The two are mostly incompatible
except for the fact that for bith by calling 's.c_str()'
you get a pointer to a C string. (Unfortunately 'String',
as the rest of all this Delphi stuff, totally ignores
'const' and gives you a non-const pointer. This is of
course stupid.)
I'd recommend using 'std::string', because this will
make your apps better portable. Where needed (VCL) you
can convert them to 'String' using their 'c_str()'
member.
> [...]
> So, sorry for my ignorance (I'm still in the learning stage of this big
> universe of the c/c++ language)
This is especially hard when you can't tell the standard
features from proprietary compiler extensions...
> but can you give me an example on how to
> use the convertToString() function?
You were almost there:
std::string sResult = convertToString(uiResult);
If you need to pass it to the VCL do it like this:
MyLabel->Text = sResult.c_str();
> Thanks,
HTH,
> Stephane.
Schobi
> [...]
AnsiString msg=Format("%2.0n ",ARRAYOFCONST(((double)(depth-(i-1)))))+
Format("Plynodes=%15.0n ",ARRAYOFCONST(((double)(plynodecount[i]))))+
Format("BF=%5.1n",ARRAYOFCONST(((double)(branchfactor))));
----- Original Message -----
From: "Stephane Lambert" <web...@sympatico.ca>
Newsgroups: borland.public.cppbuilder.language
Sent: Friday, May 18, 2001 10:44 AM
Subject: Re: Converting __int64 to String?
> Hi Larry,
>
> Some questions about the piece of code you posted.
>
> 1. What type are 'depth' and 'branchfactor'?
Sorry, depth and branchfactor are also __int64. I just quickly cut and
paste some code from my chess program.
> 2. Do I need to initialize those two precedent variables to some value?
The key thing here is to use Format. If you want to see valid results,
then
intialize whatever variable name you choose.
AnsiString msg;
__int64 somevariablename;
msg=Format("Value=%5.1n",ARRAYOFCONST(((double)(somevariablename))));
This will output the literal "Value=" followed by a number with 1
decimal point like "34.1".
The Value= was optional.
msg=Format("%5.1n",ARRAYOFCONST(((double)(somevariablename))));
This will give msg the value of the number.
> 3. Since a 'i' variable is used, I supposed there's some kind of loop.
Yes, but just because I clipped some of my code.
> So is it a 'for' or 'while' loop?
Could be either one, it does not matter.
> 4. What exactly mean the '%n.In' and '%n.On'? I couldn't found anything
> in the online help about this.
In BCB5 help, this is under Format strings.
In BCB5 help, this is under Format strings.
In BCB5 help, this is under Format strings.
> 5. Does the 'plynodecount[32]' is supposed to contain the '__int64'
> value that I want to convert to string?
Just create an __int64 with whatever variable name you want.
First, thanks a lot for your reply and your patience.
Now, when I add the line:
std::string sResult = convertToString(uiResult);
or...
String sResult = convertToString(uiResult).c_str();
I get a compiler error saying:
[C++Error] Unit1.cpp(14): Undefined structure
'std::basic_ostringstream<char,std::char_traits<char>,
std::allocator<char> >'.
In the online help it said:
"The named structure was used in the source file,
probably on a pointer to a structure, but had no definition
in the source file.
This is probably caused by a misspelled structure name
or a missing declaration."
This error points to the first line of the template declaration in the
".h" file.
template < typename T > inline std::string convertToString(T o)
{
std::ostringstream oss; // <- Line pointed by the error.
oss << o;
return oss.str();
}
And like I'd said, the template declaration is in my ".h" file and I use
it in the ".cpp" file. I'd try to transfer the template declaration in
the ".cpp" but it change nothing. I also try to include the 'stdlib.h'
and the 'cstdlib.h' in the ".h" file then in the ".cpp" file but again
the error still there. As long as I'm not using the 'convertToString()'
function (I mean just having the template declaration in the ".h" file)
no compiler error appear. But as soon as I'm using the
'convertToString()' function in the ".cpp" file, the compiler error
appear. Is there somethings missing? Or do I do somethings wrong?
By the way, I don't know if it's relevant for this case but I'm using
C++Builder 3.0.
Thanks,
Stephane.
Thanks for your reply and explanation. First I though that the whole
thing (piece of code) was the answer to my problem. Sorry. Now using
only the 'Format()' line as the following:
String sResult = Format("%n",ARRAYOFCONST(((double)(uiResult))));
This gives me an answer. But since the variable 'uiResult' contain the
result of big calculation like '10 ^ 63', and I need an integer answer,
the 'Format()' function doesn't allow me to use the 'unsigned __int64'
type. Because this following line of code...
String sResult = Format("%n",ARRAYOFCONST(((unsigned
__int64)(uiResult))));
...gives me the following compiler error...
[C++Error] Unit1.cpp(43): Could not find a match for
'System::OpenArray<System::TVarRec>
::OpenArray(unsigned __int64)'.
Maybe it is because I'm using C++Buider 3.0. Is there another way around
to convert this big result (up to 19 number) to a string (looking like
an integer value), using the 'Format()' function?
Thanks,
Stephane.
BTW, this
> template < typename T > inline std::string convertToString(T o)
> {
> std::ostringstream oss; // <- Line pointed by the error.
> oss << o;
> return oss.str();
> }
is a template definition. The corrsponding declaration
would be:
template < typename T > std::string convertToString(T o);
> And like I'd said, the template declaration is in my ".h" file and I use
> it in the ".cpp" file.
That's the way it's supposed to be.
> I'd try to transfer the template declaration in
> the ".cpp" but it change nothing.
Except when you try to use it from another .cpp file,
the linker will be upset.
> I also try to include the 'stdlib.h'
> and the 'cstdlib.h' in the ".h" file then in the ".cpp" file but again
> the error still there.
Stringstreams are in the <sstream> header.
> [...]
What book are you using to learn C++?
> Thanks,
> Stephane.
Schobi
I think there's a problem in the conversion from 'unsigned __int64' and
'char' types. Because if I try one of those following lines...
String sResult = String(sprintf("%Ld", uiResult));
or
char cResult[20] = sprintf("%Ld", uiResult);
...I get the same compiler error that is...
[C++Error] Unit1.cpp(45): Cannot convert
'unsigned __int64' to 'const char *'.
Why is it so complicated to convert 'unsigned __int64' type to a string
looking as a big integer value? First I though it was a trivial thing to
do that I was just not aware of. But now it looks like it's a more
tricky and huge task to achieve.
Thanks,
Stephane.
> Why is it so complicated to convert 'unsigned __int64' type to a
> string looking as a big integer value? do that I was just not aware
> of. But now it looks like it's a more tricky and huge task to
> achieve.
No. It is easy if done correctly.
unsigned __int64 bignum = 999999999999999I64;
AnsiString x;
x.sprintf("%I64u", x);
--
Chris (TeamB);
Well, I'd add the '#include <sstream.h>' in the ".h" file and this
resolve the problem. But guess what? Another compiler error arise, this
time pointing to the second line of the 'convertToString()' function
declaration that is 'oss << o;' and saying:
[C++Error] Unit1.h(17): Ambiguity between
'std::basic_ostream<char,std::char_traits<char> >
::operator <<(bool)'
and 'std::basic_ostream<char,std::char_traits<char> >
::operator <<(short)'.
Since I never use and even saw a template function, I just can't
understand how it work. I mean, if you ask me to explain the line
'template < typename T > inline std::string convertToString(T o)' I
could not say much about it other than 'string' is a member function of
the 'std' class and 'convertToString' is the function name and it
contain one parameter named 'o' of the 'T'. So, probably this is my
major handicap to be able to resolve the problems and properly use this
function. Again. sorry for my ignorance, but I'm always ready and happy
to learn more about c/c++ language.
About the books I'd read. First I read "Teach Yourself Borland
C++Builder in 14 Days". This book come with the C++Builder 3.0 compiler.
I also read the "Developer's Guide" that also came with the C++Builder
compiler. Now I'm just finishing "C++Builder Unleashed" by Charlie
Calvert. If you have other books to recommend that dive more deeply into
the C++ language, don't hesitate. Now I'm starving to learn more about
this language and I just can't find a book (I mean a good book) to buy.
To be honest, I saw lots of book. But I don't buy them because I do not
know if it's a good one or just a piece of...(you know what). There's so
many books out there that it's really a quest to find the good one.
Thanks,
Stephane.
Well, writing the following lines of code...
unsigned __int64 uiResult = 9999999999999999999;
String sResult;
sResult.sprintf("%I64u", uiResult);
...I get the following compiler error...
[C++Error] Unit1.cpp(50): 'sprintf' is not a member of
'System::AnsiString'.
Is it because I'm using C++Builder 3.0?
Thanks,
Stephane.
> Hi Chris,
>
> Well, writing the following lines of code...
>
> unsigned __int64 uiResult = 9999999999999999999;
> String sResult;
> sResult.sprintf("%I64u", uiResult);
>
> ...I get the following compiler error...
>
> [C++Error] Unit1.cpp(50): 'sprintf' is not a member of
> 'System::AnsiString'.
>
> Is it because I'm using C++Builder 3.0?
Yes, sprintf was added as a member of AnsiString in BCB4, and
"refined" in bcb5. You should still be able to do it into a temp
buffer:
char buf[50];
sprintf(buf, "%I64u", uiResult);
sResult = buf;
I'm assuming, of course, that Borland's RTL sprintf function supports
"I64u" as a special type for unsigned __int64 values. I haven't used
BCB3 in so long that I can't remember for sure what they have. But at
least try it.
Also note, if you don't put I64 on the end of your numeric literal,
the compiler will consider it (9999999999999999999) an unsigned
integer and it will overflow before it's ever assigned to uiResult.
--
Chris (TeamB);
It finally works. Since the online help only mentioned '%I64d,i,o,x or
X' I wasn't aware of the '%I64u' format character. Now it seem to work
without the 'I64' at the end of my numeric literal. And since my
function looks like the following:
unsigned int uiNum = StrToInt(Num->Text);
unsigned int uiPowNum = StrToInt(PowNum->Text);
unsigned __int64 uiResult = uiNum;
for(int i = 1; i < (int)uiPowNum; i++)
{
uiResult *= uiNum;
}
char buf[50];
sprintf(buf, "%I64u", uiResult);
String sResult = buf;
How can I add the 'I64' at the end of the numeric literal of 'uiResult'?
One last thing. The maximum that this function can compute is "10 ^ 63".
If I try "10 ^ 64" it return "0". How can I compute greater values like
"350 ^ 130"? Is it simply impossible?
Thanks,
Stephan.
I looked around and found that Format can convert __int64 in BCB 5.
I dont know if it works in BCB3, but here is my code and results...
__int64 svalue=1;
unsigned __int64 uvalue=1;
AnsiString ASResult;
for(int i=0;i<64;i++)
{
svalue*=2;
uvalue*=2;
AnsiString ASResult=svalue;
Memo1->Lines->Add(ASResult);
ASResult=uvalue;
Memo1->Lines->Add(ASResult);
}
2
2
4
4
8
8
16
16
32
32
64
64
128
128
256
256
512
512
1024
1024
2048
2048
4096
4096
8192
8192
16384
16384
32768
32768
65536
65536
131072
131072
262144
262144
524288
524288
1048576
1048576
2097152
2097152
4194304
4194304
8388608
8388608
16777216
16777216
33554432
33554432
67108864
67108864
134217728
134217728
268435456
268435456
536870912
536870912
1073741824
1073741824
2147483648
2147483648
4294967296
4294967296
8589934592
8589934592
17179869184
17179869184
34359738368
34359738368
68719476736
68719476736
137438953472
137438953472
274877906944
274877906944
549755813888
549755813888
1099511627776
1099511627776
2199023255552
2199023255552
4398046511104
4398046511104
8796093022208
8796093022208
17592186044416
17592186044416
35184372088832
35184372088832
70368744177664
70368744177664
140737488355328
140737488355328
281474976710656
281474976710656
562949953421312
562949953421312
1125899906842624
1125899906842624
2251799813685248
2251799813685248
4503599627370496
4503599627370496
9007199254740992
9007199254740992
18014398509481984
18014398509481984
36028797018963968
36028797018963968
72057594037927936
72057594037927936
144115188075855872
144115188075855872
288230376151711744
288230376151711744
576460752303423488
576460752303423488
1152921504606846976
1152921504606846976
2305843009213693952
2305843009213693952
4611686018427387904
4611686018427387904
-9223372036854775808
9223372036854775808
0
0
Larry.
"Stephane Lambert" <web...@sympatico.ca> wrote in message
news:3B0AA2A9...@sympatico.ca...
Hi Stephane,
> Well, I'd add the '#include <sstream.h>' in the ".h" file and this
> resolve the problem.
'#include <sstream>' would be the standard way to do this.
> But guess what? Another compiler error arise, this
> time pointing to the second line of the 'convertToString()' function
> declaration that is 'oss << o;' and saying:
>
> [C++Error] Unit1.h(17): Ambiguity between
> 'std::basic_ostream<char,std::char_traits<char> >
> ::operator <<(bool)'
> and 'std::basic_ostream<char,std::char_traits<char> >
> ::operator <<(short)'.
OK. replace 'std::basic_ostream<char,std::char_traits<char> >'
by 'std::ostream' (there's a 'typedef') and you get
Ambiguity between
'std::ostream::operator <<(bool)'
and
'std::ostream::operator <<(short)'
This means, the output operator ('<<') isn't overloaded for
'__int64' and the compiler has therefor to cast it to another
type. (I don't know what the casting rules for '__int64' are
-- it's a proprietary extension --, but the compiler obviously
can't decide what to convert it to.)
> Since I never use and even saw a template function, I just can't
> understand how it work.
Fair enough. ;^>
> I mean, if you ask me to explain the line
> 'template < typename T > inline std::string convertToString(T o)' I
> could not say much about it other than 'string' is a member function of
> the 'std' class
Wrong. 'std' is a namespace.
> and 'convertToString' is the function name and it
> contain one parameter named 'o' of the 'T'.
Yeah, and that 'T' is the key to understand the function
template. 'convertToString()' isn't a function. Instead
it's a template from which the compiler creates a function
on demand. What happens is basically, that
template< typename T >
inline std::string convertToString(T o)
{
std::ostringstream oss;
oss << o;
return oss.str();
}
when you call it like this
__int64> num = f();
std::string str = convertToString<__int64>(num);
becomes
inline std::string convertToString(__int64 o)
{
std::ostringstream oss;
oss << o;
return oss.str();
}
because the compiler replaces 'T' with '__int64'. To
make life easier, in this case you are allowed to replace
convertToString<__int64>(num)
with
convertToString(num)
because the compiler is able to deduce the template
argument from the function argument.
> So, probably this is my
> major handicap to be able to resolve the problems and properly use this
> function. Again. sorry for my ignorance, but I'm always ready and happy
> to learn more about c/c++ language.
But if you're interested, that's not ignorance! ;^>
Anyway, the road to go from here would be to overload
'operator<<()' for '__int64's, but it seems as if that
would be a little to advanced for you.
(If not, pick a good book (see below) and look this up.)
> About the books I'd read. First I read "Teach Yourself Borland
> C++Builder in 14 Days". This book come with the C++Builder 3.0 compiler.
Forget about it.
> I also read the "Developer's Guide" that also came with the C++Builder
> compiler. Now I'm just finishing "C++Builder Unleashed" by Charlie
> Calvert.
Dunno that.
> If you have other books to recommend that dive more deeply into
> the C++ language, don't hesitate. Now I'm starving to learn more about
> this language and I just can't find a book (I mean a good book) to buy.
> To be honest, I saw lots of book. But I don't buy them because I do not
> know if it's a good one or just a piece of...(you know what). There's so
> many books out there that it's really a quest to find the good one.
If you want to find good books, look into the book review
section of ACCU at www.accu.org.
What's highly praised by everyone for its new way of teaching
C++ is "Accelerated C++" by Andrew Koenig and Barbara Moo. (I
read it myself and think it's great.) For years now, the almost
standard beginner's C++ book was Stan Lippman's "C++ Primer".
That's a heavy one (>1000 pages), but it covers just about
everything one would possibly need to know about the language.
If you don't like its teaching attitude, use Bjarne Stroustrups
"The C++ Programming Language", which is _the_ book on C++, also
named "The Bible". (Actually it's not for beginners, though. But
sooner or later everyone has it on their desks...)
Thanks a lot for your advises, the crash course about template, the
books references, your kindness and your patience. Now I will try to go
on by myself about template and everything else I do not know yet and I
do must learn about the c/c++ language.
Thanks again, I really, really appreciate.
Stephane.
uiResult = 4000000000000i64;
> One last thing. The maximum that this function can compute is "10 ^ 63".
> If I try "10 ^ 64" it return "0". How can I compute greater values like
> "350 ^ 130"? Is it simply impossible?
Use a float or double, or wait until the __int128 appears. :-)
Regards,
Micha.
In BCB3 it looks like it's not as natural as in BCB5. But only minor
changes to the code and I got the same results as yours. Here's your
code posted with the modifications for BCB3. Thanks to Chris Uzdavinis
who posted this simple way to convert 'unsigned __int64' in BCB3.
__int64 svalue=1;
unsigned __int64 uvalue=1;
char buf[50]; // <- Line added.
AnsiString ASResult;
for(int i=0;i<64;i++)
{
svalue*=2;
uvalue*=2;
sprintf(buf, "%I64d", svalue); // <- Line added.
AnsiString ASResult=buf; // <- Line modified.
Memo1->Lines->Add(ASResult);
sprintf(buf, "%I64u", uvalue); // <- Line added.
ASResult=buf; // <- Line modified.
Memo1->Lines->Add(ASResult);
}
Hope it could help somebody else.
Thanks Larry,
Stephane.
In fact what I meant when I said:
> "Stephane Lambert" <web...@sympatico.ca> wrote:
> > How can I add the 'I64' at the end of the numeric literal of 'uiResult'?
Is because of this following line:
unsigned __int64 uiResult = uiNum;
Since 'uiResult' is not initialize directly to a numeric literal as
'4000000000000i64' but to the value of an unsigned integer variable as
'uiNum', my question remain, how can I add the 'I64' at the end of the
'uiResult' value?
Sorry for the bad conception of my initial question.
Thanks,
Stephane.
This code works fine:
// -- code snippet
unsigned __int64 a, b;
String A;
b = 18446744070000000000;
a = b;
A = String().sprintf("%Lu", a);
printf("%s", A.c_str());
// -- end code snippet
It seems I don't need i64 addition. The number I used is nearly the upper
limit. (So I am uncertain as to why the i64 addition is needed) I use BCB4,
BTW. I suggest you test this code too, then you will know as what you need
to do or not.
Regards,
Micha.
Of course, you would use your own separate sprintf buffer function.
Micha.
It works fine for me too without the 'I64' at the end. I just though it
was better to have the 'I64' at the end for the compiler. But since it
looks like it is not possible to add the 'I64' at the end of an
'unsigned __int64' variable when this one is initialized using another
variable's value (that is not an 'unsigned __int64') but only when a
literal value is used like 'x = 1234567899876543210I64', I supposed that
it's the way it should be. But if someone can explain to me the real
purpose of the 'I64' at the end of a numeric literal value, I will
really appreciate.
Thanks a lot for your help Micha.
Stephane.
> Hi Micha,
>
> But if someone can explain to me the real purpose of the 'I64' at
> the end of a numeric literal value, I will really appreciate.
It tells the compiler the actual type to consider the numeric
literal. In some cases you might want to be sure that the number is a
__int64 rather than a normal int. To make a clear example, consider
this program:
#include <iostream>
void foo(int) { std::cout << "int" << std::endl; }
void foo(__int64) { std::cout << "__int64" << std::endl; }
int main()
{
foo(5);
foo(5I64);
}
--
Chris (TeamB);
Thanks for your explanation.
So, if I well understood, we use the 'I64' at the end of a numeric
literal where is a potential risk of ambiguity (for the compiler) to
choose between an 'int' and an 'int__64'. Then, if there is no risk of
ambiguity (for the compiler), the use of the 'I64' at the end of a
numeric literal is not an absolute necessity.
Stephane.
> So, if I well understood, we use the 'I64' at the end of a numeric
> literal where is a potential risk of ambiguity (for the compiler) to
> choose between an 'int' and an 'int__64'. Then, if there is no risk
> of ambiguity (for the compiler), the use of the 'I64' at the end of
> a numeric literal is not an absolute necessity.
It's not just for ambiguities, though it helps. Really, what it does
is tell the compiler the actual integral type of the literal.
According to the standard, there is no __int64, nor is there the I64
suffix. However, they behave as integrals do, and play according to
integral rules.
The standard does state, however, that if you have an integral literal
without a suffix, then the actual type of that literal is determined
to be an integer, unless an integer cannot hold the value, in which
case it's a "long integer". If a long can't hold the value your
program is undefined. (Borland seems to have added another rule: if
long can't hold it, than it is considered to be __int64, and if that
can't hold it, THEN it's undefined.) However, to be more standards
compliant, it's best (IMHO) to use a suffix to tell the compiler what
type you want.
For example, you can use the 'L' (or lowercase 'l') character after an
integral literal to tell the compiler "this is a long int" (choosing
the first fitting type in the list (unsigned int, long int, unsigned
long int). You can use the 'U' (or lowercase 'u') to indicate you
want unsigned, in which case it will select the first fitting type in
the following set of types (unsigned int, unsigned long int). If
suffexed by [Ll][Uu] (some combination of upper and/or lower case
letters LU) then the type is unsigned long int.
See ANSI 2.13.1 P2 for a list of all the rules of how literals are
interpreted in different conditions.
So when you want to specify a type, you can use the suffix to say what
it is. It's not extremely useful, but does have its purposes when
precise control over types is needed.
--
Chris (TeamB);
Thanks a lot for your kindness and explanations. It greatly contribute
to develop my knowledge about this wonderful but sometimes complicated
language that is the C/C++. I really appreciate.
Again thanks,
Stephane.