Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Integer Literal Question

Reply
Thread Tools

Integer Literal Question

 
 
Nephi Immortal
Guest
Posts: n/a
 
      12-28-2012
I would like to ask a question about integer literal.

Let's see my example below. I wonder if the suffix i(n) is the standard C++ Compiler and is compatible to portable ANSI or is it Microsoft extension?

If the integer in the range 0 through 65535, then int type is chosen on 32 bit machine or long long type on 64 bit machine.

void Do( char x ) {}
void Do( signed char x ) {} // never used unless you declare (signed char) name
void Do( unsigned char x ) {}

void Do( wchar_t x ) {}

void Do( signed short x ) {}
void Do( unsigned short x ) {}

void Do( signed int x ) {}
void Do( unsigned int x ) {}

void Do( signed long x ) {}
void Do( unsigned long x ) {}

void Do( signed long long x ) {}
void Do( unsigned long long x ) {}

int main()
{
Do( 'a' ); // call Do( char x )
Do( L'a' ); // call Do( wchar_t x )

Do( 0x7F ); // call Do( signed int x )
Do( 0x7FFF ); // call Do( signed int x )
Do( 0x7FFFFFFF ); // call Do( signed int x )
Do( 0x80000000 ); // call Do( unsigned int x ) on 32-bit machine
Do( 0x80000000 ); // call Do( signed long long x ) on 64-bit machine

Do( 0x7FFFFFFFFFFFFFFF ); // call Do( signed long long x )

Do( 0x80i8 ); // call Do( char x )
Do( 0x8000i16 ); // call Do( signed short x )
Do( 0x80000000i32 ); // call Do( signed int x )
Do( 0x8000000000000000i64 ); // call Do( signed long long x )

Do( 0x80ui8 ); // call Do( unsigned char x )
Do( 0x8000ui16 ); // call Do( unsigned short x )
Do( 0x80000000ui32 ); // call Do( unsigned int x )
Do( 0x8000000000000000ui64 ); // call Do( unsigned long long x )

Do( 0x7Fl ); // call Do( signed long x )
Do( 0x7FFFl ); // call Do( signed long x )
Do( 0x7FFFFFFFl ); // call Do( signed long x )

Do( 0x7Fll ); // call Do( signed long long x )
Do( 0x7FFFll ); // call Do( signed long long x )
Do( 0x7FFFFFFFll ); // call Do( signed long long x )

return 0;
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generates integer literal of the largest value a variable can hold.Macro takes only variable-name. John Reye C Programming 14 05-08-2012 04:40 AM
CType(x,Integer) vs. Integer.Parse(x) =?Utf-8?B?Sm9l?= ASP .Net 7 02-07-2006 02:30 AM
Comparing Char Against Integer Literal Zach C++ 3 12-12-2004 08:02 PM
What's wrong with rpc-literal? Why use doc-literal? Anonieko Ramos ASP .Net Web Services 0 09-27-2004 09:06 AM
No Math.min(Integer, Integer)? =?ISO-8859-1?Q?Thomas_Gagn=E9?= Java 0 07-29-2003 07:46 PM



Advertisments