absolute value? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: absolute value? (
/showthread.php?tid=257441)
absolute value? -
sciman001 - 26.05.2011
How can i make a function that returns the absolute value of a number?
Respuesta: absolute value? -
admantis - 26.05.2011
https://sampwiki.blast.hk/wiki/Floatabs
Re: absolute value? -
sciman001 - 26.05.2011
thats ONLY for floats...
Respuesta: Re: absolute value? -
admantis - 26.05.2011
Quote:
Originally Posted by sciman001
thats ONLY for floats...
|
Use it as a float and round it into an integer.
https://sampwiki.blast.hk/wiki/Floatround
Re: absolute value? -
sciman001 - 26.05.2011
wait... what? y cant i just make a function? i dont get wut u mean...
Quote:
Use it as a float and round it into an integer.
|
Respuesta: absolute value? -
admantis - 26.05.2011
For example, just use the normal floatabs function to get the absolute value of a Float and then round it with floatround so it's a integer.
pawn Код:
printf("%d", floatround(floatabs(-47.00)));
// Will print 47.
Re: absolute value? -
sciman001 - 26.05.2011
yes, but i need to get the absolute of a NON float VARIABLE, and if i convert it to float, it screws up the whole script... wut i do?
Respuesta: absolute value? -
admantis - 26.05.2011
Use this function then:
pawn Код:
stock abs(int)
{
if (int < 0)
return -int;
else
return int;
}
Re: absolute value? -
sciman001 - 26.05.2011
THANK YOU SOOO MUCH DUDE! ALL I NEEDED!!! THX!!!
Re: absolute value? -
Steven82 - 26.05.2011
Quote:
Originally Posted by sciman001
THANK YOU SOOO MUCH DUDE! ALL I NEEDED!!! THX!!!
|
What you need is some math skills...