Pawn with formula calculation
#9

Quote:
Originally Posted by thefatshizms
Посмотреть сообщение
That's verry weird... I've basically copied the exact formula and it still won't work. My try:

pawn Код:
stock formula(l)
{
    new a = 0;
    for(new x = 1; x < l; x++)
    {
        a += floatround(x+300*floatpower(2, (x/7)), floatround_floor);
    }
    return floatround(a/4, floatround_floor);
}

public OnFilterScriptInit()
{
    for(new i = 1; i < 100; i++)
    {
        printf("%i", formula(i));
    }
}
I've just changed my
pawn Код:
for(new i = 1; i<4; i++)
to
pawn Код:
for(new Float:i = 1; i<4; i++)
And this seems to work if i=1, but further than that it doesn't work. If i=2 result = 91.92 but in the PHP one it should be result = 175

I'm not the best at maths so it's probably something else I'm doing wrong.

This is what I've got now:
pawn Код:
new Float:formula, Float:result, Float:base = 300, string[128];
    for(new Float:i = 1; i<4; i++)
    {
        formula = (i+base*floatpower(2, (i/7)));
        result = (formula/4);
        format(string, sizeof(string), "For Input: %i, Formula = %i, Result = %i", floatround(i), floatround(formula), floatround(result));
        SendClientMessage(playerid, 0xCCFF00AA, string);
    }
Reply


Messages In This Thread
Pawn with formula calculation - by V1ceC1ty - 27.09.2014, 11:33
Re: Pawn with formula calculation - by thefatshizms - 27.09.2014, 11:39
Re: Pawn with formula calculation - by V1ceC1ty - 27.09.2014, 11:45
Re: Pawn with formula calculation - by thefatshizms - 27.09.2014, 11:52
Re: Pawn with formula calculation - by V1ceC1ty - 27.09.2014, 12:03
Re: Pawn with formula calculation - by Vince - 27.09.2014, 12:08
Re: Pawn with formula calculation - by V1ceC1ty - 27.09.2014, 12:09
Re: Pawn with formula calculation - by thefatshizms - 27.09.2014, 12:28
Re: Pawn with formula calculation - by V1ceC1ty - 27.09.2014, 12:31
Re: Pawn with formula calculation - by thefatshizms - 27.09.2014, 12:41

Forum Jump:


Users browsing this thread: 1 Guest(s)