What about this commands?
#21

It took me a while to figure out how the last part of the floating-point number works:
pawn Код:
f2b(Float: f)
{
    new Float: fractional = floatfract(f), fract, binary[20];

    for (new i; i != 8; i++)
    {
        if((fractional *= 2.0) > 1.0)
        {
            fractional -= 1.0;

            if (!fract) fract = 1;
            else fract = fract * 2 + 1;
        }
        else
        {
            if (fract) fract *= 2;
        }
    }

    format(binary, sizeof binary, "%b.%b", floatround(f, floatround_floor), fract);
    return binary;
}
The only difference between mine and yours (in results) is that fractional 0.0 will give 11111111 (255) for you while mine will stay at 0.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)