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.

6th Apr 2017, 8:57 AM
Alex Snaidars
Alex Snaidars - avatar
6 Respostas
+ 9
That's not irrational, that is a complex number.
6th Apr 2017, 9:36 AM
Karl T.
Karl T. - avatar
+ 9
A complex number has the form a+b*i where a and b are real. Square root of -1 for example is i.
6th Apr 2017, 11:22 AM
Karl T.
Karl T. - avatar
+ 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...
6th Apr 2017, 12:37 PM
Karl T.
Karl T. - avatar
0
@Helioform So that has specific name or symbol for that, right?
6th Apr 2017, 11:17 AM
Alex Snaidars
Alex Snaidars - avatar
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?
6th Apr 2017, 12:32 PM
Alex Snaidars
Alex Snaidars - avatar
0
Great advice for a quadratic equation solver program :) Anyway, I will just use my sqrt!=sqrt abs
6th Apr 2017, 12:50 PM
Alex Snaidars
Alex Snaidars - avatar