Hi, I just found that there may be a bug existing in

the following function, which is in scalfunc.cpp:

inline int needed_bits(int n)

As a simple test, I tried the integers from 1 to 15

and the result was as follows:

# Int, Calculated bits needed, Actually bits needed

n = 1, b = 0, 1 ->wrong calculation by the function

n = 2, b = 1, 2 ->wrong calculation by the function

n = 3, b = 2, 2

n = 4, b = 2, 3 ->wrong calculation by the function

n = 5, b = 3, 3

n = 6, b = 3, 3

n = 7, b = 3, 3

n = 8, b = 3, 4 ->wrong calculation by the function

n = 9, b = 4, 4

n = 10, b = 4, 4

n = 11, b = 4, 4

n = 12, b = 4, 4

n = 13, b = 4, 4

n = 14, b = 4, 4

n = 15, b = 4, 4

Please let me know if I am correct. Thank you.