How do I calculate the square root of a negative number?

Tekla Tedds for Word
2021
Tekla Tedds Tekla Tedds for Word
2020
Tekla Tedds Tekla Tedds for Word
2019
Tekla Tedds Tekla Tedds for Word
2018
Tekla Tedds Tekla Tedds for Word
2022
Tekla Tedds Tekla Tedds for Word
2023
Tekla Tedds Tekla Tedds for Word
2024
Tekla Tedds Tekla Tedds for Word
numeric range error

Some calculations may require you to calculate the square root of a negative number due to the previously calculated or defined values but this will result in an expression error. A possible workaround is to compare the calculated value with a very small number and the square root the maximum of the two.

Here's a very simple example:

works OK if ‘x’ is positive
x = 200
y = 20
z = SQRT(x/y) = 3.162


but there’s an error if ‘x’ is negative
x = -200
y = 20
z = SQRT(x/y) = ? <Error: numeric range error>

Workaround

x = 200
y = 20
z = SQRT( max( x/y , 0.0001 )) = 3.162

x = -200
y = 20
z = SQRT( max( x/y , 0.0001 )) = 0.010

 
Cela a-t-il été utile?