Microsoft DirectX 8.0 (C++)

log

Provides log2(x) support with full float precision of at least 1/220.

log   vDest, vSrc0

Registers

vDest
Destination register, holding the result of the operation.
vSrc0
Source register, specifying the input argument.

Operation

    SetDestReg();
    SetSrcReg(0);

    float v = ABSF(m_Source[0].w);
    if (v != 0)
    {
        m_TmpReg.x = m_TmpReg.y = m_TmpReg.z = m_TmpReg.w = 
            (float)(log(v)/log(2));  
    }
    else
    {
        m_TmpReg.x = m_TmpReg.y = m_TmpReg.z = m_TmpReg.w = minUS_INFINITY();
    }

    WriteResult();

Expansion

This macro takes twelve instruction slots.

Remarks

This instruction accepts a scalar source .w of which the sign bit is ignored. The result is replicated to all four channels.

The input exponent must be in the range –128 to 128. The approximation error must be less than 1/220 in absolute error, and over the range 1.0 less than or equal to t.y less than 2.0. A zero source generates (-infinity,-infinity,-infinity,-infinity).