[Haskell] for large x, log (x::Integer) :: Double

Jan-Willem Maessen - Sun Labs East Janwillem.Maessen at Sun.COM
Thu Jul 1 10:49:46 EDT 2004

Steve Schafer wrote:
> 4) Use your CPU's built-in floating-point unit to compute g, the base-2
> log of q. (For an Intel CPU, see the FYL2X instruction. If q is very
> close to 1, you may want to use the FYL2XP1 instruction instead to
> preserve more significant bits; in that case, pass it q - 1 rather than
> q.)

My colleague from the Java-for-x86 world reminds me that the 
floating-point transcendentals on x86 are chock full of little 
infelicities which limit the conditions under which they may be used.

My feeling is you want to understand these infelicities before you 
start using the instructions in your code.  (For example, you should 
be able to explain, and correct, Mr. Shafer's explanation of FYL2X 
versus FYL2XP1 above when 0.5 <= q <= 1.0.  I haven't quite figured it 
out myself...)

Here be dragons.  For the rest of us, there are very nice 
floating-point libraries.  If you're lucky, their authors actually did 
the above work... :-)


More information about the Haskell mailing list