[Haskell-cafe] Re: Float instance of Data.Bits
sergueyz at gmail.com
Fri Jul 9 10:49:10 EDT 2010
2010/7/9 Sam Martin <sam.martin at geomerics.com>:
>> Some operations wouldn't make much sense with Float, for instance the
>> 'complement' function. What should it return? Also note that bit
>> manipulation functions could cover only a small window of the value
>> range. So it could happen that x .|. y = x, even though y is nonzero.
>> Also rotation would be a destructive operation.
> Perhaps I can illustrate this with an example. It's very common with SSE
> code to interpret a float as both a mask and a number. You can exchange
> the two freely.
> For instance, in c-like pseudo code, you can write:
> float mask = myval == 0 ? 0x00000000 : 0xffffffff
Notwithstanding mask is compatible with float sizeof-wize you should
assign it a different type so you won't accidentally return a value of
It is cumbersome in C, and much more easier in Haskell.
Then you specify your operations over masks and floats, bind them to
SSE2 primitives and use them as you wish.
More information about the Haskell-Cafe