absolute value?
#1

How can i make a function that returns the absolute value of a number?
Reply
#2

https://sampwiki.blast.hk/wiki/Floatabs
Reply
#3

thats ONLY for floats...
Reply
#4

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
Reply
#5

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.

Reply
#6

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

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

Use this function then:
pawn Код:
stock abs(int)
{
    if (int < 0)
        return -int;
    else
        return int;
}
Reply
#9

THANK YOU SOOO MUCH DUDE! ALL I NEEDED!!! THX!!!
Reply
#10

Quote:
Originally Posted by sciman001
Посмотреть сообщение
THANK YOU SOOO MUCH DUDE! ALL I NEEDED!!! THX!!!
What you need is some math skills...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)