www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/21/11:04:48

From: G DOT DegliEsposti AT ads DOT it
To: "Henri Ossi" <henri DOT ossi AT mail DOT htk DOT fi>
cc: djgpp AT delorie DOT com
Message-ID: <C12565ED.0051D521.00@vega.ads.it>
Date: Tue, 21 Apr 1998 16:54:34 +0200
Subject: Re: Separating two 8bit numbers from 16bit
Mime-Version: 1.0




> Now I'm trying to store a 16bit number as two ASCII characters to my
file.
> So, I was wondering, if there's a fast way to separate a 16bit number to
two
> 8bit numbers?
>
> I know, that I can do this easily with inline asm (and I also can do it),
> but is there a fast and short way to do this in C?
this would rather belong to comp.lang.c, but anyway:

short n;
unsigned char ch, cl;

ch = n >> 8;
cl = n & 0xff;

ciao
  Giacomo



- Raw text -


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