Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top