IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Re: much slower, too
Not necessarily. It depends on the code and optimization. If for example you have successive tests (i.e. nested IFs or complex condition) that use the variables sharing a byte or int some economies are possible.

Suppose you had two booleans sharing a byte:

x bxxxxxxx -- where b is the bit for that boolean and likewise
y xbxxxxxx

With a single fetch from memory (with a LOAD machine instruction) you can put both variables in a CPU register. With a single "AND IMMEDIATE" instruction (with 11000000) you can set the "condition code" for the JUMP instruction that tests the condition. That would be handy if you had

if ( x | y )...

Otherwise, the variables need to be loaded and tested separately requiring a larger number of machine instructions and more execution time.

When these variables are unrelated in the code, then indeed time might be wasted by the need to isolate or extract the needed bits from the cohabitants.

Frankly, this kind of thinking should be a thing of the past except for embedded applications with limited resources, e.g. controlling an electric toothbrush. :)
Alex

The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt. -- Bertrand Russell
New Well, embedded applications, yes...
...but not for the reasons you state.

One of the best uses for bit fields is setting/getting hardware registers that have an annoying tendency to pack several command and/or status bit fields of varying length into a single 8-, 16-, or 32-bit register. Most of you web services types (not meant perjoritavely) are so far away from the hardware you never have to mess with such stuff (and probably good riddance, from your perspective, no?). However, even on 32-bit embedded processors (note: over 50% of new embedded designs are with 32-bit processors), bit fields most definitely have their place.

They are also useful for packing data into communication streams. But one must remember that bit fields are explicitly non-portable, so using them to communicate between dissimilar architectures, or even similar architectures with differernt compilers, is more than a bit tricky.
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New Re: "not for the reasons you state"
What I had in mind was something like Motorola 6802 (perhaps before your time :)), an 8-bit microprocessor with 128 BYTES of on chip RAM. You would put your code on a separate ROM chip of say 8 KB, but all you had was that measly 128 bytes for memory. So packing bits in bytes was mandatory.
Alex

The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt. -- Bertrand Russell
New I'll see your 6802...
...and raise you an Intel 8748: 64 BYTES of on-chip RAM (which also included the two register sets and the stack...oh, wait a minnit-that 64 BYTES was the stack... and 2KB of on-chip EEPROM. Used it to make an IEEE-488 interface controller for light-pipe data acquisition controllers for an EMP measurement system.

And no, it is definitely not before my time... ;-).
jb4
shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT

New :-)
Alex

The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt. -- Bertrand Russell
     C Structure Question - (johnu) - (13)
         Re: C Structure Question - (admin) - (1)
             Re: C Structure Question - (johnu)
         :1 allows you to pack multiple members in one word - (Arkadiy) - (8)
             Yuck... - (johnu)
             Read the Cocoa headers - (tuberculosis)
             Re: much slower, too - (a6l6e6x) - (4)
                 Well, embedded applications, yes... - (jb4) - (3)
                     Re: "not for the reasons you state" - (a6l6e6x) - (2)
                         I'll see your 6802... - (jb4) - (1)
                             :-) -NT - (a6l6e6x)
             Re: :1 allows you to pack multiple members in one word - (jb4)
         more than 1 bit is possible too - (SpiceWare)
         It does work with JNIWrapper! - (johnu)

MY SUGGESTIONS ARE THE RESULT OF COUNTLESS NANOSECONDS OF COGITATION! HOW DARE YOU REJECT THEM?!?
118 ms