How to filter error ints?

Hi,
my problem is simple, but i didnt found solution for it. I have function, that does something including x^0.5 and sometimes it return this -nan(ind), bec it i am doing this sometimes with negative number (i cant square root real number, when they are negative, bec when i do -*-, i will get +), but i have problem, that i need to detect, if the function returned this or some number, but i have no idea how to do it. What i tried is getting type of it, but i found, that they are both number.

2 Likes

No, i dont need this, bec the error in square root is saying, that this is impossible (i am using it in balistic curve), but i need to add if (best, when i can have it otside of the function), that will fire, when it returns the error (btw, for your solution, this will return bad result, bec when it is negative, it will need to be complex number (example: -4^0,5=2i))

1 Like

Oh alright, sorry for the misunderstanding.

1 Like

What number are you using to get -nan(ind)?
I have an idea, but I need to test if it works.

What do you mean, to get -nan(ind), you must do -d^2.

What do you give for d?
I can’t achieve it.

1 Like

I am solving this

2c5c375af9d89e403690dceeb6d074eab6ed27fe

and when the number, that i am square rooting is negative, there isnt any result, and i need to make if, that does something, when the result, what this return is the mistake, and it will be best, when i can have this if outside the function (ok, i can return second parametr, and that will be, if it is negative, but it is much code, so it will be easier, when i can do this by comparing it to something, that it will return true if it is -nan(ind))

tostring(math.sqrt(-x)) == "-nan(ind)" will always return true if it is -nan(ind)