Author Topic: subtracting 2 hex numbers problem  (Read 6527 times)

skitzofrenzy

  • Guest
subtracting 2 hex numbers problem
« on: September 16, 2012, 01:37:41 am »
Running C::B on Win7, GNU compiler, default settings


Im trying to subtract to numbers in hex and keep an index of the results, but running into one complication:

My output keeps spitting out extra digits in front of my output. I understand that it is showing that it is a negative number, however i need to figure out how to limit the output to what I want it to show.

basic rundown

short ax, bx;
ax = 0x0120;
bx = ox0250;

ax=ax-bx;
printf("%.4X", ax);

and it is outputting FFFFFED0. Desired is simply FED0.
Probably an easy way to limit this, but it escapes me. Any insight appreciated.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: subtracting 2 hex numbers problem
« Reply #1 on: September 16, 2012, 01:54:16 am »
This forum/website is neither a general programming forum, nor a support forum for any compilers.

With registering here, you have accepted to respect the forum rules.

Your post clearly violates these rules, because it is not related to C::B in any way, but to the compiler you use.

Topic locked !!

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: subtracting 2 hex numbers problem
« Reply #2 on: September 16, 2012, 08:47:19 am »
I normal do not put PM's send to me in the public part of the forum, no I do:
Hey so I understand if you dont want the help forum getting crowded with junk, but you locking my thread does no help, and thats kinda the point of this forum.

Maybe think I didnt know the problem is from my compiler??????????? maybe you could have just helped me really quick??????????

I havent written anything in C in a while, so Im a little rusty, thus why im on C::B. Kick me off if you want to but there is no reason to just be rude

It looks you still did not read the rules or you want to ignore them.
Do you think we mad the rules just for fun aor you do not need to follow them, just you can get help without searching yourself.
I might have been able to help you or not, but his is irreleveant.

There are a lot of C/C++-specific help forums out in the wilderness, and I guess your question was answered there already.
Reading compiler/language related documentation might also help.

I'm sure you can learn to find the answer yourself.
Just try to use yor favourite search engine.

If you still believe you don't need to follow the rules, because you can get a quicker answer here, and try it again, you might get banned without any further warning.