Difference between revisions of "LlSqrt"

From Second Life Wiki
Jump to navigation Jump to search
m (LSL llSqrt moved to LlSqrt: removing prefix)
(NaN returned under Mono)
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func=llSqrt|sort=Sqrt
|func=llSqrt|sort=Sqrt
|func_id=4
|func_id=4|func_sleep=0.0|func_energy=10.0
|func_sleep=0.0
|func_footnote=For imaginary results (val < 0.0), a {{LSLGC|Error/Math|Math Error}} is triggered under LSO , or 'NaN' (Not A Number)  is returned under Mono
|func_energy=10.0
|p1_type=float|p1_name=val|p1_desc=positive number (val &gt;= 0.0)
|func_footnote=Triggers a [[LSL_Math_Error|Math Error]] for imaginary results (val < 0.0)
|p1_type=float|p1_name=val|p1_desc=positive number (val >= 0.0)
|return_type=float
|return_type=float
|return_text=that is the square root of val.
|return_text=that is the square root of {{LSLP|val}}.
|spec
|spec
|caveats=* Crashes the script if passed a negative number.
|caveats=* Crashes the script if passed a negative number.
|constants
|constants
|examples
|examples=
<source lang="lsl2">
default
{
  state_entry()
  {
    float num1 = llFrand(100.0);
 
    llOwnerSay("The square root of " + (string)num1 + " is " + (string)llSqrt(num1));
  }
}
</source>
|helpers
|helpers
|also_functions
|also_functions={{LSL DefineRow||[[llLog]]|}}
{{LSL DefineRow||[[llLog10]]|}}
{{LSL DefineRow||[[llPow]]|}}
|also_events
|also_events
|also_articles
|also_articles
|also_tests
|also_tests
|notes
|notes=If you need the square root of two use [[SQRT2]].
|permission
|permission
|negative_index
|negative_index
Line 24: Line 35:
|cat3
|cat3
|cat4
|cat4
|haiku={{Haiku|Gleaming in the sun|the water gun lays broken.|It's SQuare RooT not SQuiRT.}}
}}
}}

Revision as of 14:35, 13 January 2016

Summary

Function: float llSqrt( float val );

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.
All Issues ~ Search JIRA for related Bugs

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 use SQRT2.

See Also

Functions

•  llLog
•  llLog10
•  llPow

Deep Notes

Search JIRA for related Issues

Signature

function float llSqrt( float val );

Haiku

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