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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…