|
Boost : |
From: Matthew Hurd (matt_at_[hidden])
Date: 2002-08-02 05:32:01
Octet for 8 bits? Nibblies for hexadecimal... Not really required me
thinks.
If you can do binary and ternary digits then you've got odd and even numbers
of bits covered at the detail level... The rest can be implemented via
"digit" sets, aka bitsets for binary, by mapping the number of bits required
for the maximal range required for your bits and pieces of thingos :-)
state<N> seems a good idea perhaps with an enum or typelist mapping of names
of states. Implementation could use a sequence of bits for a state. Then
again this naming would be easy to confuse with status bits in a bitset
where you might expect to take the union or intersection of statuses,
(statii?).
maybe "digit_radix<3>" or digit<3> or simple_state<3, names( yep, nope,
gedouddahere) > are better thoughts
state_group< stupid_states, curly_states, mo_states> or some such where the
number of bits is optimal to contain all the possible states, that is the
product of all states.
That said a tri-state bool (oxymoron?) / digit / logic would be handy
without all the other fluff.
$0.00002
matt.
PS: unary digits will be a challenge as you'll keep ending up with an
infinite number
----- Original Message -----
From: "Daniel Frey" <daniel.frey_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, August 02, 2002 7:16 PM
Subject: Re: [boost] Re: 3-state boolean type
> "Philippe A. Bouchard" wrote:
> >
> > > > I've just placed a 3-state boolean type in the sandbox, available
here:
> > > >
> > > Maybe it can make sense also to create tribool_bitset<> and
> > vector<tribool>.
> > > /Pavel
> >
> > I would suggest using a 'quadbool' instead in this case because
> > vector<tribool> won't be optimal at all to reserve bits since tribool
> > already takes 2 bits... why not a 2 bits quadbool?... Let's say: true,
> > false (1st bit), probably true, probably false (2nd bit).
>
> It depends on what you need. Sometimes, a tribool is needed, sometimes a
> quadbool. I even had a case to store a quintbool. The names are somewhat
> ugly, as it is no longer a "bool", I thus suggest calling it:
>
> tristate, quadstate and quintstate or state3, state4, state5 or
> state<N>?
>
> As a short explanation of what I used the quintstate for:
>
> Consider a series of integers. Now detect when it crosses zero without
> the possibility to backreference previous values. You are passed one
> value after another. Of course you might store the old value, but this
> has one problem: When the first 10000 values are all 0, you have to
> store them all to preserve the state :) You need to store when they are
> the same and what the previous state was. In the beginning the state was
> '0,unknown', as long as the series is 0, is remains '0,unknown'. later
> it became '+', '-', '0,previously+' or '0,previously-'.
>
> What I'd like to express by this example is the problem of the
> enumerated values and especially their identifiers. It depends on your
> usage and it's hard no find names that fit nice into every context.
> Well, yet another problem but no solution - maybe someone else has an
> enlightening idea :)
>
> Regards, Daniel
>
> --
> Daniel Frey
>
> aixigo AG - financial training, research and technology
> Schloß-Rahe-Straße 15, 52072 Aachen, Germany
> fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
> eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk