Question about data types in C++

Status
Not open for further replies.

Lucifre

Full Member level 2
Joined
Jul 5, 2005
Messages
125
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,296
Location
Detroit MI
Activity points
2,389
Often in my C++ book i see variables initialized as

Code:
long lg = 0x654321;

or

Code:
long DELAY = 10000L;

my question is what do those letter characters do in there? do they change value or what do they do?
 

I'm sure u know 0x stands for hexadecimal.
I've never seen 'L' at the end, though!

Giri
 

hi
L postfix shows the number is in long type. but in this case (long lg=1000L) it is not necessary to write it. in some case its better to write L at the end of ur number
(it's a way of type casting)

anx 0X prefix shows the number is in HEX format
0x1 --> 1
.
.
.
0xa -->10
.
.
.
0xff -->255

and so on.
 

Following on from above; the L postfix forces the compiler to acknoledge the constant as long.
 

Ok i get it now, but... can that be done with postfix for other data types such as integers shorts etc?
 

hi
no postfix. for constants but u can use from type casting for variables:

x=(short)y;

and
others...
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…