SA-MP Forums Archive
Returning simple math calculation - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Returning simple math calculation (/showthread.php?tid=444025)



Returning simple math calculation - Income - 14.06.2013

Hi there,

I was trying to exchange Int to Float in order to get percentage of a specific amount.
Take a look at this stock:

pawn Код:
stock Calculate()
{
    return (70 / 100);
}
By following simple math, it should return 0.7; however, it shows 0.
Am I totally wrong here? Or something else causing it.

NOTE: I tried to use Float as well but it gave me the same result: 0.00000....

Does anyone can give me a hand out here? Much appreciated.


AW: Returning simple math calculation - HurtLocker - 14.06.2013

use float(70)/float(100)


Re: AW: Returning simple math calculation - Income - 14.06.2013

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
use float(70)/float(100)
I see.
pawn Код:
stock Calculate()
{
    new Float:FloatValue = float(70);
    new Float:Result = float(100);
    return (FloatValue / Result); // warning 213: tag mismatch
}
What appears to be the problem though?


AW: Returning simple math calculation - HurtLocker - 14.06.2013

pawn Код:
stock Calculate()
{
    return (float(70)/float(100));
}



Re: AW: Returning simple math calculation - Income - 14.06.2013

Quote:
Originally Posted by HurtLocker
Посмотреть сообщение
pawn Код:
stock Calculate()
{
    return (float(70)/float(100)); //warning 213: tag mismatch
}
Did you even tried to compile it yourself?
It gives me an error: warning 213: tag mismatch.


Re: Returning simple math calculation - Kirollos - 14.06.2013

try out
pawn Код:
stock Calculate()
{
    return _:(float(70) / float(100));
}



AW: Returning simple math calculation - HurtLocker - 14.06.2013

pawn Код:
stock Calculate()
{
    new Float:result=float(70)/float(100);
    return result;
}