Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #4136

Re: boolean usage

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: boolean usage
Date 2011-05-16 17:46 -0700
Organization None to speak of
Message-ID <lnoc32duh3.fsf@nuthaus.mib.org> (permalink)
References <1e11781e-486c-414d-acbc-7d6447000270@f9g2000vbz.googlegroups.com> <oqpvs65m9oual4tldng627nj8vt9a0qi97@4ax.com> <lnzkmmfzrg.fsf@nuthaus.mib.org> <lld3t61s069bk9l1f2jkr0u2mbmb1cqlhe@4ax.com>

Show all headers | View raw


Datesfat Chicks <datesfat.chicks@gmail.com> writes:
> On Mon, 16 May 2011 08:09:39 -0700, Keith Thompson <kst-u@mib.org>
> wrote:
[...]
>>Either your tools are generating C code that emulates 1-bit objects
>>using either bit fields or bitwise operations, or your C compiler
>>is non-conforming.  In standard C, if you apply sizeof to an object,
>>type, or expression of any type, the result is at least 1 byte,
>>which is at least 8 bits.  (sizeof can't be applied to bit fields.)
>
> Interesting discussion.  I wasn't aware it was non-comforming.
>
> I consider it a gift from The Heavens.  Every one of those variables
> saves 7 bits of RAM!
[...]

In some environments, the 7 bits of RAM saved for each Boolean
stored in 1 bit rather than 8 would be more than wiped out by the
increase in the size of the code needed to access it.

The tradeoff could well be different in your environment, either if
no extra machine code is needed to access single bits (depends on
the CPU, or if space for variables is in much shorter supply than
code space (ROM?).

For large arrays of booleans, of course, it's a different story.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

boolean usage "dr.oktopus" <blindwilly@freeonline.zzn.com> - 2011-05-14 14:05 -0700
  Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-14 16:41 -0700
    Re: boolean usage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-15 04:18 +0100
  Re: boolean usage "dr.oktopus" <blindwilly@freeonline.zzn.com> - 2011-05-14 23:12 -0700
  Re: boolean usage Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-05-14 23:39 -0700
    Re: boolean usage "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-19 21:29 -0400
      Re: boolean usage Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-05-19 22:49 -0700
        Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-20 09:17 -0700
          Re: boolean usage gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-20 17:14 +0000
  Re: boolean usage Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-15 10:58 -0400
    Re: boolean usage Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-05-15 08:12 -0700
    Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-16 08:09 -0700
      Re: boolean usage Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-16 19:44 -0400
        Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-16 17:46 -0700
          Re: boolean usage Datesfat Chicks <datesfat.chicks@gmail.com> - 2011-05-16 22:45 -0400
  Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-16 18:23 -0700
    Re: boolean usage Jens <jens.gustedt@gmail.com> - 2011-05-16 23:37 -0700
      Re: boolean usage James Kuyper <jameskuyper@verizon.net> - 2011-05-17 06:39 -0400
        Re: boolean usage "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-05-17 09:55 -0400
          Re: boolean usage James Kuyper <jameskuyper@verizon.net> - 2011-05-17 21:17 -0400
      Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-17 16:50 -0700
        Re: boolean usage Jens <jens.gustedt@gmail.com> - 2011-05-18 09:21 -0700
          Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-18 15:36 -0700
            Re: boolean usage Jens <jens.gustedt@gmail.com> - 2011-05-19 00:20 -0700
              Re: boolean usage Ralf Damaschke <rwspam@gmx.de> - 2011-05-19 09:04 +0000
            Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-19 01:13 -0700
              Re: boolean usage Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-05-19 03:29 -0700
              Re: boolean usage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-19 11:41 +0100
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-19 11:24 -0700
                Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-19 11:55 -0700
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-19 14:40 -0700
                Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-19 15:48 -0700
                Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-23 18:26 -0700
                Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-23 18:29 -0700
                Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-23 18:27 -0700
                Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-24 00:11 -0700
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-24 00:48 -0700
                Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-24 09:16 -0700
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-24 10:10 -0700
                Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-24 10:48 -0700
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-25 10:18 -0700
                Re: boolean usage gazelle@shell.xmission.com (Kenny McCormack) - 2011-05-19 21:53 +0000
                Re: boolean usage Michael Press <rubrum@pacbell.net> - 2011-05-25 11:22 -0700
                Re: boolean usage Kenneth Brody <kenbrody@spamcop.net> - 2011-05-25 16:10 -0400
                Re: boolean usage Michael Press <rubrum@pacbell.net> - 2011-05-26 12:32 -0700
                Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-19 22:39 -0700
                Re: boolean usage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-20 12:57 +0100
                Re: boolean usage Peter Nilsson <airia@acay.com.au> - 2011-05-22 17:52 -0700
                Re: boolean usage Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-23 13:15 +0100
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-24 00:57 -0700
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-24 01:38 -0700
                Re: boolean usage Keith Thompson <kst-u@mib.org> - 2011-05-24 09:20 -0700
                Re: boolean usage Tim Rentsch <txr@alumni.caltech.edu> - 2011-05-24 11:00 -0700

csiph-web