Abs value
#1

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

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)
Reply
#3

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 Thanks!
Reply
#4

pawn Код:
stock abs( value )
{
   return ( ( value < 0 ) ? ( value * -1 ) : ( value ) );
}
Reply
#5

Edit:Nvm lol
Reply
#6

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));
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)