Integer square root?
#1

Hi, I just need a define that gets the square root of an integer.


What i've already tried:
pawn Код:
#define sqrt(%0) _:(floatsqroot(Float:%0)) // returned random huge numbers

#define sqrt(%0) floatround(floatsqroot(Float:%0)) // always returns 0
Thanks!
Reply
#2

Just use:
pawn Код:
floatsqroot(number);
and the output is a float.
Reply
#3

But I need it to return an integer, too. Wait, got an idea...
Reply
#4

https://sampwiki.blast.hk/wiki/Floats#Float_-.3E_Integer
Reply
#5

Got it working. Simpler than it seemed to be. Thanks!

pawn Код:
#define sqrt(%0) floatround(floatsqroot(%0))
Reply
#6

EDIT: Didn't noticed that it was solved.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)