Re: bsr-algorithm?



Why didn't you tell us that up front?

Didn't expect somebody want's to crack his head with me.

Please specify exactly what your input format is, and what you need as
the final output!

My input format is any integer-type, my output is any float-format
(even custom ones with let's say 1.15.16).

The short input is probably signed 16-bit values, right?

For that function, yes. Can be a long, long long or quadl too.

How should they be converted, i.e. which features of the input do you
actually need to extract?

Can you post a pseudo-code version of the full algorithm?

Pseudo, no, real yes:

inline void importl(const DataType tht) {
DataType t = tht;

/* prepare value and set sign */
bitfield = ZEROp;
/* zero (no negative zero possible) */
if (t == 0)
return;
/* negative (two's complement) */
if (t < 0)
bitfield = ZEROn, t = -t;

/* scan size */
// DataType e = (size - 1) - lzcnt(t);
DataType e = fbpos(t);

/* exponent too big */
if (e > BIAS) {
bitfield |= INFp;
return;
}

/* scan size */
DataType s = fraction - e;

/* fraction too big */
if (s < 0)
t >>= -s, s = 0;

/* normalize fraction and done */
bitfield |= ((e + BIAS) << fraction) | ((t << s) & MAXf);
}

I gave up searching for a MMX version of it (and SSE, ...).
Not because of the branches, but because of the fbpos() I absolutely
couldn't figure out a basic mmx/xmms-solution.

Ciao
Niels

.


Quantcast