www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/08/13:45:30

From: jwright AT adtran DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: simple question :)
Date: Tue, 06 Oct 1998 19:37:51 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 42
Message-ID: <6vdrif$ipb$1@nnrp1.dejanews.com>
References: <36176419 DOT 4E27BA8 AT cdworld DOT co DOT uk> <6vcujm$2dt$1 AT antares DOT lu DOT erisoft DOT se>
NNTP-Posting-Host: 206.166.249.100
X-Article-Creation-Date: Tue Oct 06 19:37:51 1998 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)
X-Http-Proxy: 1.1 x4.dejanews.com:80 (Squid/1.1.22) for client 206.166.249.100
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <6vcujm$2dt$1 AT antares DOT lu DOT erisoft DOT se>,
  Martin DOT Stromberg AT lu DOT erisoft DOT se (Martin Stromberg) wrote:
> Craig Rothwell (craig AT cdworld DOT co DOT uk) wrote:
> : I have 2 numbers 12 (18)  and
> : 212 (d4) and I want to convert
> : them into one number.
>
> : I know the number I want is 6356
> : but i don't know how to get it.
> : Can someone send me the right
> : code?
>
> How about (12 < 212 ? 6356 : 0)?
>
> Right,
>
> 							MartinS
>

Try this:

#include <stdio.h>

int main( void )
{
  int a, b, c;

  a = 12;
  b = 18;
  c = ( a << 16 ) + b;

  printf("\nCombine 12 and 18 to get %d,\n", c);
  printf("  or in hex 0x%04X\n, c);
}

This converts two bytes to one integer.  Make sure you check endian
for the CPU you will use.

J-man

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019