# Getting square root of a number in Julia – sqrt() and isqrt() Methods

Last Updated : 26 Mar, 2020
The `sqrt()` is an inbuilt function in julia which is used to return the square root of the specified number and throws DomainError for negative Real parameter. It also accept complex negative parameter.
Syntax: sqrt(x) Parameters:
• x: Specified values.
Returns: It returns the square root of the specified number and throws DomainError for negative Real parameter. It also accept complex negative parameter.
Example:
 `# Julia program to illustrate  ``# the use of sqrt() method `` ` `# Getting the square root of the  ``# specified number and throws DomainError ``# for negative Real parameter ``println(sqrt(``9``)) ``println(sqrt(``16``)) ``println(sqrt(``complex``(``-``25``))) ``println(sqrt(``-``49``)) `

Output:
```3.0
4.0
0.0 + 5.0im
sqrt will only return a complex result if called with a complex argument. Try sqrt(complex(x)).
Stacktrace:
[1] sqrt(::Int64) at ./math.jl:434
```

#### isqrt()

The `isqrt()` is an inbuilt function in julia which is used to return integer square root of the specified value. The largest returned integer value m(say) such that
Syntax: isqrt(n::Integer) Parameters:
• n::Integer: Specified values.
Returns: It returns integer square root of the specified value.
Example:
 `# Julia program to illustrate  ``# the use of isqrt() method `` ` `# Getting integer square root of the specified value. ``println(isqrt(``12``)) ``println(isqrt(``17``)) ``println(isqrt(``5``)) ``println(isqrt(``227``)) `

Output:
```3
4
2
15
```

Previous
Next