Difference between revisions of "LlSqrt"
Jump to navigation
Jump to search
Frionil Fang (talk | contribs) m (note about other roots, since they are sometimes useful) |
|||
(24 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LSL_Function | ||
|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 >= 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); | |||
llOwnerSay("The square root of " + (string)num1 + " is " + (string)llSqrt(num1)); | |||
} | |||
} | |||
</source> | |||
|helpers | |||
|also_functions={{LSL DefineRow||[[llLog]]|}} | |||
{{LSL DefineRow||[[llLog10]]|}} | |||
</ | {{LSL DefineRow||[[llPow]]|}} | ||
| | |also_events | ||
| | |also_articles | ||
|also_tests | |||
|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 | |||
|negative_index | |||
|cat1=Math | |||
|cat2=Error/Math | |||
{| | |cat3 | ||
| | |cat4 | ||
| | |haiku={{Haiku|Gleaming in the sun|the water gun lays broken.|It's SQuare RooT not SQuiRT.}} | ||
| | }} | ||
| | |||
| | |||
| | |||
| [[ | |||
|} | |||
| | |||
| | |||
| | |||
| | |||
| | |||
| | |||
= | |||
| | |||
| | |||
| | |||
| | |||
|} | |||
Latest revision as of 12:51, 11 October 2023
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
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));
}
}