Re: [ Re: buggy ia64_fls() ? (was Re: /dev/random problem on 2.6.12-rc1)]

From: David Mosberger <>
Date: 2005-04-09 06:46:29
>>>>> On Fri, 8 Apr 2005 10:48:39 -0700, Matt Mackall <> said:

  Matt>  return ia64_getf_exp(d) & 0x3f;

  Matt> is the right fix. The fact that it's using floating point
  Matt> is... weird.


Why is it that so many Linux developers have this knee-jerk "weird"
reaction whenever they see something that they didn't expect?


OK, I feel better now, so in the hope that you're curious to know how
this works: if you know about floating-point numbers, you know that
after each operation, the FPU has to normalize the result.  Given
that, it's clearly something that an FPU will do "fast" (in constant
time).  Furthermore, normalization is nothing more than shifting bits
left until the most-significant bit is 1 and counting (in the
exponent) how many shifts you had to do.  Now, if you have an FPU unit
which can represent a full 64-bit value in the mantissa (which is the
case for ia64), presto, you got a very efficient way to do fls().  As
mentioned earlier, there may be reasons why it's not the best
solution, but in my book it certainly counts as an elegant solution.

To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to
More majordomo info at
Received on Fri Apr 8 16:47:04 2005

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:37 EST