forked from len0rd/rockbox
Undo hacks to meant to get around string formatting limitations
The new vuprintf makes unnecessary workarounds due to formatting limitations. I checked grep output for whatever appeared to fit but it's possible I missed some instances because they weren't so obvious. Also, this means sound settings can dynamically work with any number of decimals rather than the current assumption of one or two. Add an ipow() function to help and take advantage of dynamic field width and precision. Consolidate string formatting of sound settings. Change-Id: I46caf534859dfd1916cd440cd25e5206b192fcd8
This commit is contained in:
parent
5c9688961e
commit
aced667f48
13 changed files with 110 additions and 142 deletions
|
@ -211,6 +211,35 @@ long fp_sqrt(long x, unsigned int fracbits)
|
|||
return g;
|
||||
}
|
||||
|
||||
/* raise an integer to an integer power */
|
||||
long ipow(long x, long y)
|
||||
{
|
||||
/* y[k] = bit k of y, 0 or 1; k=0...n; n=|_ lg(y) _|
|
||||
*
|
||||
* x^y = x^(y[0]*2^0 + y[1]*2^1 + ... + y[n]*2^n)
|
||||
* = x^(y[0]*2^0) * x^(y[1]*2^1) * ... * x^(y[n]*2^n)
|
||||
*/
|
||||
long a = 1;
|
||||
|
||||
if (y < 0 && x != -1)
|
||||
{
|
||||
a = 0; /* would be < 1 or +inf if x == 0 */
|
||||
}
|
||||
else
|
||||
{
|
||||
while (y)
|
||||
{
|
||||
if (y & 1)
|
||||
a *= x;
|
||||
|
||||
y /= 2;
|
||||
x *= x;
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixed point sinus using a lookup table
|
||||
* don't forget to divide the result by 16384 to get the actual sinus value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue