Hi Art,

I'm not sure of the value of an int log2 as it could lead to incorrect
results i.e.

    log2(10.0f) =3.32..
    log2(10)=3

Clearly the later is wrong.  Now if a developer wants to explictly do
a floor to get the value 3 then this is what they've asked for, but
for log2 to behave like a floor(log2()) in one case but not in others
is asking for problems.

If one is to make such an int implement then one should name it
differently.  Right now I feel that its probably appropriate to remove
the int version of log2 completely to avoid potential pitfalls.

Robert.

On 9/11/07, Art Tevs <[EMAIL PROTECTED]> wrote:
> Hi, Robert.
>
> As a result of the discussion in the osg-users list
> (post: "Please test SVN version of OpenSceneGraph") I
> created a new patch for the Math functions, which
> should solve the problem of integer binary logarithm.
>
> So here again a summarize of the patch:
>
> -----------------------
> Features:
> - new functions log2 for types: float, double, int and
> unsigned int were added to the Math header
> - integer log2 do compute the binary logarithm of an
> (unsigned) integer number
> - returns -1 on errors or a floored logarithm back
> (e.g log2(15) = 3, log2(16) = 4, log2(31) = 4)
>
> Testings:
> - made an explicit speed test. On my System (AMD
> Opteron 2218) the integer version is faster than the
> double version.
> - made error test against double version of the log2:
> no errors were found.
>
>
> ToDo:
> - nothing
> -----------------------
>
> The file is attached. It is the same as I posted in
> the osg-users list. But since this is the right list
> to post the patches, I do post it again here.
>
> I think the patch should fix the build problems on an
> MS compilers, which do not include a log2 function
> into their math.h headers.
>
> Best regards, Art
>
>
>
>
>
>       ________
> Yahoo! Clever: Stellen Sie Fragen und finden Sie Antworten. Teilen Sie Ihr 
> Wissen. www.yahoo.de/clever
>
> _______________________________________________
> osg-submissions mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org
>
>
>
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to