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.

how to convert long int into int??

Status
Not open for further replies.

skarthikshines

Member level 5
Joined
Feb 21, 2011
Messages
81
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,060
hi
how can i convert the long int into signed int ??
 

mind to give some example? and which processor are you using?

as a long int is a signed number of 64 bits (assuming an common PC compiler) a signed int is a signed number of 32 bits

you just discard the upper 32 bits and hope that you don't loose important data.

this can be achieved with a simple cast:
Code:
long int a;
signed int bc;

...


bc = (signed int)a;

...

//simple approach that works in many compilers

bc = a; //yep, it works!

some compilers will issue a wanrning for loosing some bits in the middle of the convertion...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top