Microsoft DirectX 8.0 (Visual Basic)

logp

Provides log2(x) partial support.

logp   vDest, vSrc0

Registers

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

Operation

The following code fragment shows the operations performed by the logp instruction to write a result to the destination.

    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();

Remarks

This instruction provides logarithm base 2 partial precision. It generates an approximate answer in vDest.z and allows for a more accurate determination of vDest.x + function(vDest.y), where function is a user approximation to log2(vDest.y) over the limited range (1.0 <= vDest.y < 2.0).

The logp instruction accepts a scalar source of which the sign bit is ignored, and reduced precision arithmetic is acceptable in evaluating vDest.z. The approximation error must be less than 1/(211) in absolute error (10-bit precision), and over the range (1.0 <= t.y < 2.0). A zero source argument generates the result vector (-infinity, 0.0, -infinity, 1.0).

The following example illustrates how the logp instruction might be used.

logp r0,r1