https://bitbucket.org/daniel_fort/magic-lantern
Raw File
Tip revision: 11f1972f866a384f8d51b23853ba393cdc0cc60c authored by dannephoto on 12 August 2017, 20:40:14 UTC
Commit reading fpmutil tool(fpm files in specific ml-dng version in Switch) Thanks a lot B!
Tip revision: 11f1972
imath.c
/* integer math */

#include "dryos.h"
#include "math.h"

int powi(int base, int power)
{
    int result = 1;
    while (power)
    {
        if (power & 1)
            result *= base;
        power >>= 1;
        base *= base;
    }
    return result;
}

int log2i(int x)
{
    int result = 0;
    while (x >>= 1) result++;
    return result;
}

int log10i(int x)
{
    int result = 0;
    while(x /= 10) result++;
    return result;
}

/* todo: integer-only implementation? */
uint32_t log_length(int v)
{
    if (!v) return 0;
    return (unsigned int)(log2f(v) * 100);
}
back to top