ILog2 Function
Calculate the integer part of the logarithm base 2 of an integer.

Unit
QESBPCSMath

Declaration
Function ILog2(const I: LongWord): LongWord;

Description
Developed by Rory Daulton and used with Permission.

An Exception is raised if I is Zero.

Parameters
Positive Integer Value to process.

Category
Arithmetic Routines for Integers

Implementation

function ILog2 (const I: LongWord): LongWord;

procedure BadILog2;
     begin
          raise EMathError.Create (rsDivideByZero);
     end {BadILog2};
asm
    bsr     eax,eax
    jz      BadILog2
End;


HTML generated by Time2HELP
http://www.time2help.com