[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: (OT) Defining Variables in C with Bases other than 2 or 16



On Mon, 14 Feb 2005 08:25:05 -0600
Martin McCormick <martin@dc.cis.okstate.edu> wrote:

> 	There is a way in C to define boolean variables as in:
> 
> typedef char		boolean;		/* boolean data type */
> 
> 	Is there a similar method of defining a variable such as base
> 12 or 24 or any arbitrary value?
> 
> 	Thanks.
> 

You can use structs with bitfields. See for example
http://publications.gbdirect.co.uk/c_book/chapter6/bitfields.html

Take note though that you won't really save much space here since due to CPU and
memory access limitations the data sizes are always rounded at least to the
closest builtin type (char(8),short(16),long/word(32)).

There are usually architecture limitations dictating aligning requirements on
data.

> 
> Martin McCormick WB5AGZ  Stillwater, OK 
> OSU Information Technology Division Network Operations Group
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
>  
>  +++++++++++++++++++++++++++++++++++++++++++
>  This Mail Was Scanned By Mail-seCure System
>  at the Tel-Aviv University CC.
> 



Reply to: