otopp / libfixmath

Automatically exported from code.google.com/p/libfixmath
0 stars 0 forks source link

Probably error in log2 functions test for skipping decimal part #27

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
line 132 in fix16_exp.c reads:
    if(x == 0) return (result << 16);

but it probably should be
    if(x == 1) return (result << 16);

If I understand correctly this is to test if x was dividable by 2. In other 
words, do we need to calculate decimal part.

So if x was 2^n then x is 1 after the while loop as 2^0 is 1.

Original issue reported on code.google.com by raphen...@gmail.com on 19 Dec 2013 at 2:06