Absolute and Round
#1

Hi! There are these functions in Pawno?
Make absolute a variable, like abs(x) or something like this? (for example, -6 makes 6)
Round a variable, like round(x) or something else? (for example, 1.4 makes 1, 1.6 makes 2, and go on...)
If I need an Include, can you give me the file, please?
Reply
#2

floatabs
floatround
Reply
#3

Use this stock for absolute
pawn Код:
stock abs(digit)
{
    return ((digit < 0) ? (digit * -1) : (digit));
}
and for round

https://sampwiki.blast.hk/wiki/Floatround
Reply
#4

floatround
Floatround method

pawn Код:
stock Absolute(value)
{
    if(value < 0) {
        value = value * -1;
    }
    return value;
}
I didn't see the posts above
Reply
#5

Thank you !
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)