Difference between revisions of "LlSqrt"

From Second Life Wiki
Jump to navigation Jump to search
(NaN returned under Mono)
m (note about other roots, since they are sometimes useful)
 
Line 28: Line 28:
|also_articles
|also_articles
|also_tests
|also_tests
|notes=If you need the square root of two use [[SQRT2]].
|notes=*If you need the square root of two, you can use the constant [[SQRT2]].
*Other roots can be computed by [[llPow]]('''val''', 1.0/'''root''').
|permission
|permission
|negative_index
|negative_index

Latest revision as of 11:51, 11 October 2023

Summary

Function: float llSqrt( float val );
0.0 Forced Delay
10.0 Energy

Returns a float that is the square root of val.

• float val positive number (val >= 0.0)

For imaginary results (val < 0.0), a Math Error is triggered under LSO , or 'NaN' (Not A Number) is returned under Mono

Caveats

  • Crashes the script if passed a negative number.

Examples

default
{
  state_entry()
  {
    float num1 = llFrand(100.0);

    llOwnerSay("The square root of " + (string)num1 + " is " + (string)llSqrt(num1));
  }
}

Notes

  • If you need the square root of two, you can use the constant SQRT2.
  • Other roots can be computed by llPow(val, 1.0/root).

See Also

Functions

•  llLog
•  llLog10
•  llPow

Deep Notes

Signature

function float llSqrt( float val );

Haiku

Gleaming in the sun
the water gun lays broken.
It's SQuare RooT not SQuiRT.