SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Discussion

Reply
 
Thread Tools Display Modes
Old 07/12/2016, 08:06 PM   #21
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,844
Reputation: 1399
Default Re: What about this commands?

It took me a while to figure out how the last part of the floating-point number works:
pawn Code:
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.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Login/Register using ZCMD SSCANF & Y_INI.( Admin commands + VIP System + VIP Commands! ) Zh3r0 Filterscripts 116 09/01/2015 11:57 AM
Few problems with admin commands + player commands. zClaw Scripting Help 0 05/12/2013 12:36 PM
My Filterscript makes it so no server commands work (IE. Commands in the GM) [MM]18240[FMB] Scripting Help 16 19/07/2012 12:46 AM
Transforming zcmd's commands to regular commands nuriel8833 Help Archive 17 08/01/2011 06:41 AM
DCMD Commands not working after adding some ZCMD commands :S [L3th4l] Help Archive 4 20/01/2010 10:57 PM


All times are GMT. The time now is 04:22 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.