Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP Path: utzoo!watmath!rbutterworth From: rbutterworth@watmath.UUCP (Ray Butterworth) Newsgroups: net.lang.c Subject: Re: Boolean Operators Slighted in C Message-ID: <2496@watmath.UUCP> Date: Fri, 9-May-86 09:16:30 EDT Article-I.D.: watmath.2496 Posted: Fri May 9 09:16:30 1986 Date-Received: Sat, 10-May-86 07:03:50 EDT References: <838@ihwpt.UUCP> <656@osu-cgrg.UUCP> Distribution: net Organization: U of Waterloo, Ontario Lines: 24 > > lots of us say "typedef short bool" in our .h files. > typedef char bool; uses less space on some machines. And on some machines it uses more space. Some machines can reference an int with a single instruction, but checking the value of a byte might take several. The one I am using now does the "if(integer)" test in 4 bytes of machine instructions, but "if(character)" takes 12 bytes. So defining it as short or char instead of int might save you 1 or 3 bytes of storage, but it also might cost you several times this amount EVERY time you reference the variable. In general you should always use int (or long). short (or char) should only be used for structures read in from an external source or for large arrays where the saving in space for the data is significantly large. Of course if you aren't worried about portable efficiencies do whatever is best for your machine. On the other hand, I'd like to think that at least some of the software I write now will still be running in 10 years, but I have my doubts about whether or not some of the machines I am using now will still be here then. (I can think of some wonderful code I wrote for an IBM1620 not much more than 10 years ago.)