Velocity Reviews > Bit twiddling/manipulation question

# Bit twiddling/manipulation question

Flash Gordon
Guest
Posts: n/a

 06-25-2007
Barry Schwarz wrote, On 25/06/07 18:11:
> On Mon, 25 Jun 2007 01:55:04 -0700, Keith Thompson <(E-Mail Removed)>
> wrote:
>
>> Barry Schwarz <(E-Mail Removed)> writes:
>>> On Mon, 25 Jun 2007 08:12:59 +0100, Flash Gordon
>>> <(E-Mail Removed)> wrote:
>>>> Barry Schwarz wrote, On 25/06/07 00:50:

>> [...]
>>>>> Is there any guarantee that a double will be properly aligned for a
>>>>> float?
>>>> No. There is also no guarantee that sizeof(double) >= 2*sizeof(float)
>>> My question was about alignment, not size. To rephrase as a concrete
>>> example, is it legal for a system to align doubles on 4-byte
>>> boundaries but require a float to be on an 8-byte boundary.

>>

> Yes he did; I glossed over the "also".
>
> This entire subthread was meant as a rhetorical question criticizing
> Malcolm McLean's solution which cast a double* to a float*. I guess
> I'm unknowingly approaching the RH level of subtlety.

Actually, I realised that, I was just supporting the possibility of
there being problems by suggesting yet another problem with his solution.

Of course, this stems from the OP trying to do something that may not be
possible.

> Sorry Richard but you have company whether you want it or not.

Perhaps I am getting too subtle as well
--
Flash Gordon

Keith Thompson
Guest
Posts: n/a

 06-25-2007
http://www.velocityreviews.com/forums/(E-Mail Removed)-cnrc.gc.ca (Walter Roberson) writes:
[...]
> There is also no certainty of support for a bitfield of 20 bits.
> "unsigned fraction" is "unsigned int fraction", and C only requires
> int to be 16 bits wide (but larger is allowed for implementations.)
> C89 at least does not support bitfields of type 'long' or
> 'unsigned long', the minimum required to be certain of 20 bit fields.

That hasn't changed in C99; the only types guaranteed to be supported
for bit fields are int, unsigned int, signed int, and _Bool.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"