0
Irrational expressions
Is there any keywords for irrationals like the result of Math.sqrt(-5) ? I see in the output NaN, I want something like that.
6 Answers
+ 9
That's not irrational, that is a complex number.
+ 9
A complex number has the form a+b*i where a and b are real. Square root of -1 for example is i.
+ 8
It exists. It's used a lot in physics and engineering. You need to define a class to calculate it.
Just don't pass negative values to sqrt...
0
@Helioform
So that has specific name or symbol for that, right?
0
@Helioform
Sorry, maybe it's an advanced math topic, I study in high school, we just draw a circle and cross it to show that sqrt(-1) doesn't exist.
Can I use any symbols that represent it like
if (Math.sqrt(x)==NaN) {} or I must do
if (Math.sqrt(x)!=Math.sqrt(Math.abs(x))){} to detect it?
0
Great advice for a quadratic equation solver program :)
Anyway, I will just use my sqrt!=sqrt abs