Difference between revisions of "LlSqrt"

From Second Life Wiki
Jump to navigation Jump to search
m (note about other roots, since they are sometimes useful)
 
(23 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{lowercase|llSqrt}}
{{LSL_Function
__NOTOC__
|func=llSqrt|sort=Sqrt
|func_id=4|func_sleep=0.0|func_energy=10.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
|p1_type=float|p1_name=val|p1_desc=positive number (val &gt;= 0.0)
|return_type=float
|return_text=that is the square root of {{LSLP|val}}.
|spec
|caveats=* Crashes the script if passed a negative number.
|constants
|examples=
<source lang="lsl2">
default
{
  state_entry()
  {
    float num1 = llFrand(100.0);


{| width="100%"
    llOwnerSay("The square root of " + (string)num1 + " is " + (string)llSqrt(num1));
|-
  }
|<div id="box">
}
== [[LSL_Type_float|float]] llSqrt( [[LSL_Type_float|float]] val); ==
</source>
<div style="padding: 0.5em">
|helpers
* val - positive number.
|also_functions={{LSL DefineRow||[[llLog]]|}}
</div>
{{LSL DefineRow||[[llLog10]]|}}
</div>
{{LSL DefineRow||[[llPow]]|}}
|-
|also_events
|
|also_articles
<div id="box">
|also_tests
 
|notes=*If you need the square root of two, you can use the constant [[SQRT2]].
== Specification ==
*Other roots can be computed by [[llPow]]('''val''', 1.0/'''root''').
<div style="padding: 0.5em">
|permission
Returns the square root of val.
|negative_index
Returns 0 and triggers a Math Error for imaginary results
|cat1=Math
 
|cat2=Error/Math
{|
|cat3
|-
|cat4
| Energy:
|haiku={{Haiku|Gleaming in the sun|the water gun lays broken.|It's SQuare RooT not SQuiRT.}}
| 10
}}
|-
| Sleep:
| 0
|-
| [[LSL_Function_ID|Function ID]]:
| 4
|}
</div>
</div>
|-
|
<div id="box">
 
== Caveats ==
<div style="padding: 0.5em">
</div>
</div>
 
|-
|
<div id="box">
== Examples ==
<div style="padding: 0.5em">
<lsl>
</lsl>
</div>
</div>
|-
|
<div id="box">
== Helper Functions ==
<div style="padding: 0.5em">
<lsl>
</lsl>
</div>
</div>
|-
|
<div id="box">
== See Also ==
<div style="padding: 0.5em">
</div>
</div>
|-
|
<div id="box">
== Notes ==
<div style="padding: 0.5em">
</div>
</div>
|}
 
[[Category:LSL_Functions]]
[[Category:LSL_Math]]

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.