You are currently not logged in! Enter your authentication credentials below to log in. You need to have cookies enabled to log in.
This shows you the differences between two versions of the page.
functions:llsqrt [2014-05-21 11:27 SLT] sei created |
functions:llsqrt [2015-02-04 18:10 SLT] (current) sei style |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | $nav | ||
===== Function: llSqrt ===== | ===== Function: llSqrt ===== | ||
Line 5: | Line 6: | ||
</code> | </code> | ||
- | Return the square root of the argument, that is, the number that multiplied by itself gives the argument. | + | Return the square root of the argument, that is, a number such that when multiplied by itself, results in the given argument. |
===== Parameters ===== | ===== Parameters ===== | ||
=== fval === | === fval === | ||
- | The [[types/float]] value to take the square root of. | + | The $lty[float] value to take the square root of. |
- | ===== Result ===== | + | ===== Return value ===== |
- | The square root of the given float. | + | The square root of the given $ty[float]. |
===== Notes ===== | ===== Notes ===== | ||
- | * If you need the square root of 2, using [[constants/SQRT2]] instead of calling this function will save code and processing time. | + | * If you need the square root of 2, using $lct[SQRT2] instead of calling this function will save code and processing time. |
- | * Any value less than zero will return **NaN** under Mono and crash with a math error under LSO. | + | * An input of -0.0 will return -0.0. |
+ | * Any value less than zero will return $nan. | ||
===== Short examples ===== | ===== Short examples ===== | ||
Line 25: | Line 27: | ||
<code lsl2> | <code lsl2> | ||
float f; | float f; | ||
- | f = llSqrt(4); // sets f to 2.0 because 2*2=4 | + | f = llSqrt(4); // sets f to 2.0 because 2*2=4 |
f = llSqrt(25); // sets f to 5.0 because 5*5=25 | f = llSqrt(25); // sets f to 5.0 because 5*5=25 | ||
+ | f = llSqrt(2); // sets f to approx. 1.414214, which multiplied by itself gives approx. 2 | ||
+ | f = SQRT2; // same as above, but more efficient | ||
f = llSqrt(-1); // sets f to NaN (Not a Number) under Mono; crashes under LSO | f = llSqrt(-1); // sets f to NaN (Not a Number) under Mono; crashes under LSO | ||
</code> | </code> | ||
Line 32: | Line 36: | ||
===== See also ===== | ===== See also ===== | ||
- | * [[llPow]] raises a number to any power. | + | * $lfn[llPow] raises a number to any power. |
- | * [[constants/SQRT2]] is a constant with the square root of 2. | + | * $lct[SQRT2] is a constant with the square root of 2. |
+ | * $lty[float] type and associated caveats and limitations. | ||