delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/31/11:15:05

Reply-To: <arfa AT clara DOT net>
From: "Arthur" <arfa AT clara DOT net>
To: "DJGPP Mailing List" <djgpp AT delorie DOT com>
Subject: RE: short int and unsigned char
Date: Fri, 31 Jul 1998 15:04:32 +0100
Message-ID: <000001bdbc8c$2426ae40$674e08c3@arthur>
MIME-Version: 1.0
Importance: Normal
In-Reply-To: <199807302138.XAA10684@d1o22.telia.com>

> Hi!
> I wonder how big a short int is (in bits) and if there are anything smaller
> then an unsigned char (1, 2, 4 bits). I also wonder if there is any command
> to read and write a single bit in a variable.

A short int (or "short") is two bytes, AKA a word.

The smallest usable block of memory is a byte (unsigned char). This contains 8 bits.
You can use individual bits of this char, by using methods such as bitfields etc. You
can change specific bits, but not directly in binary - you have to use hex or decimal
numbers. For instance, if an unsigned char is set to 0, then no bits are set. If the
char is 1, then the first bit is set; if 2 then the second bit is set; if 3 then the
first and second bits are both set...

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819

- Raw text -


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