I see what you mean. But if a developer write something like this:
int a, b;
..
a = log2(10.0f);
b = log2(10);
then in the compiler would assign the correct function and the result will be
the same what the developer means.
Other case:
float a, b;
...
a = log2(10.0f);
b = log2(10);
a will have the correct float result. I think for the b the compiler would give
some warning, since it is not clear which functions to use (with the float
result or int result). Here the developer has to write log(float(10)) instead
to be precise.
I am going to test it now, but still have to wait until it compiles ;-)
Another suggestion would be to rename the function into blog2 or logb2 and use
this function in the Texture*.cpp files, where it was used.
Art
Robert Osfield <[EMAIL PROTECTED]> schrieb: 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 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
---------------------------------
Wissenswertes für Bastler und Hobby Handwerker.BE A BETTER HEIMWERKER!_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org