Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

unsigned int subtraction...

Status
Not open for further replies.

hhhsssmmm

New Member
Here is a simple question that im confused on...plz can someone answer it...

Im using C18 compiler....

if i use "unsigned int".... and then subtract two integers in such a way that the one which is subtracted is greater
than the one from which im subtracting...forexample...

result = small - big;

this should give me a result that does not care about the -ve sign....am i correct?....so forexample

result = 2 - 4;

the 'result ' value then contains the variable '2'.....ignoring the -ve sign

is this correct?

please can someone correct me.

thank you
Haseeb
 
No, if you use unsigned int then 2-4=65534 which is the unsigned value of -2.

If you explain what you are trying to do we may be able to make suggestions.

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top