Re: Artifact bitfield full? Or can I use the high bits?
- From: James <james.kanze@xxxxxxxxx>
- Date: Tue, 17 Feb 2009 15:53:00 -0800 (PST)
On Feb 18, 12:22 am, Doug Freyburger <dfrey...@xxxxxxxxx> wrote:
Justin Hiltscher <jus...@xxxxxxxxxxxxxxxxxx> wrote:
Doug Freyburger <dfrey...@xxxxxxxxx> wrote:
Here's my take on bit fields - Assume a long is 32 bits
then don't use the sign bits just out of convervatism.
That leaves 28 bits available. Any work on these bits
will break save files so just do it and consider the work
a reset. There are plenty of bits left available.
Er... 32 bits of unsigned int means 31 bits of signed int
and 1 bit for the sign. You're either negative, or you're
not.
Call me paranoid then - The rare times I use bit fields I
avoid the sign bit of each byte. Byte addressing machines
might view any one byte or any length of bytes ending at a
byte as a flexible sized integer and I like to avoid sign bits
out of paranioa.
I go one step further, and declare the type unsigned (and never
access it other than as the type it is declared). That way,
there are no sign bits to worry about.
Of course, most of the time I use bit fields, it is in order to
be compatible with some external format (TCP header, etc.). In
which case, I use the bits the format requires:-).
--
James Kanze (GABI Software) email:james.kanze@xxxxxxxxx
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
.
- Follow-Ups:
- References:
- Artifact bitfield full? Or can I use the high bits?
- From: guns
- Re: Artifact bitfield full? Or can I use the high bits?
- From: Patric Mueller
- Re: Artifact bitfield full? Or can I use the high bits?
- From: Gregory Weston
- Re: Artifact bitfield full? Or can I use the high bits?
- From: Patric Mueller
- Re: Artifact bitfield full? Or can I use the high bits?
- From: Doug Freyburger
- Re: Artifact bitfield full? Or can I use the high bits?
- From: Justin Hiltscher
- Re: Artifact bitfield full? Or can I use the high bits?
- From: Doug Freyburger
- Artifact bitfield full? Or can I use the high bits?
- Prev by Date: Re: Artifact bitfield full? Or can I use the high bits?
- Next by Date: Re: All 4 zen roles: sam, wiz, rog and tou
- Previous by thread: Re: Artifact bitfield full? Or can I use the high bits?
- Next by thread: Re: Artifact bitfield full? Or can I use the high bits?
- Index(es):
Relevant Pages
|