Returning simple math calculation
#1

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.
Reply
#2

use float(70)/float(100)
Reply
#3

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?
Reply
#4

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

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.
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)