Abs 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: Abs value (
/showthread.php?tid=213205)
Abs value -
Nonameman - 18.01.2011
Hey!
I wanna get an integer's abs value, but pawno only have floatabs function.
Is there any ways to do it without forming it into float?
Re: Abs value -
Calgon - 18.01.2011
No, you'll have to convert it to a float, using Float().
(without using a custom function, unless you consider Grim_'s solution which is based on a custom function)
Re: Abs value -
Nonameman - 18.01.2011
Quote:
Originally Posted by Calgon
No, you'll have to convert it to a float, using Float().
|
Hmm, okey, I just wanted to know it
![Smiley](images/smilies/smile.png)
Thanks!
Re: Abs value -
Grim_ - 18.01.2011
pawn Код:
stock abs( value )
{
return ( ( value < 0 ) ? ( value * -1 ) : ( value ) );
}
Re: Abs value -
Backwardsman97 - 18.01.2011
Edit:Nvm lol
Re: Abs value -
PowerPC603 - 18.01.2011
Quote:
Originally Posted by Grim_
pawn Код:
stock abs( value ) { return ( ( value < 0 ) ? ( value * -1 ) : ( value ) ); }
|
This can be made alittle shorter too:
pawn Код:
stock abs( value )
{
return ((value < 0 ) ? (-value) : (value));
}