Difference between revisions of "LlModPow"

From Second Life Wiki
Jump to navigation Jump to search
(has been fixed, and forced delay removed)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{LSL_Function
{{LSL_Function
|func_id=300|func_sleep=1.0|func_energy=10.0
|func_id=300|func_sleep=0.0|func_energy=10.0
|func=llModPow|return_type=integer
|func=llModPow|sort=ModPow
|return_type=integer
|p1_type=integer|p1_name=a
|p1_type=integer|p1_name=a
|p2_type=integer|p2_name=b|p2_desc=capped at 0xFFF (16 bits)
|p2_type=integer|p2_name=b
|p3_type=integer|p3_name=c
|p3_type=integer|p3_name=c
|func_footnote
|func_footnote
|func_desc  
|func_desc
|return_text=that is '''a''' raised to the '''b''' power, mod '''c'''. ( ('''a'''**'''b''')%'''c''' )
|return_text=that is '''a''' raised to the '''b''' power, mod '''c'''. ( ('''a'''**'''b''')%'''c''' )
|spec
|spec
|caveats=*'''b''' is capped at 0xFFF (16 bits)
|caveats
|constants
|constants
|examples
|examples=<syntaxhighlight lang="lsl2">
integer x = llModPow(13743, 14200, 10000); // = 1
integer y = llModPow(0xc734abfa, 0x8371b314, 0xffffffff); // = -1481328730, corresponding to unsigned value of 2813638566
</syntaxhighlight>
|helpers
|helpers
|also_functions
|also_functions
Line 17: Line 21:
|also_tests
|also_tests
|also_articles
|also_articles
|notes
|notes=*Internally, the parameters are considered unsigned integers. This means it's possible to get extra range by using negative values or hexadecimal, and interpreting the result as such as well.
|permission
*This function used to have a forced delay of 1.0 and precision issues before an update in January 2025.{{footnote|Reported {{date|2024-11-03}}, fixed in January 2025: https://feedback.secondlife.com/scripting-bugs/p/getting-wrong-results-from-llmodpow}}
|negative_index
|cat1=Math
|sort=ModPow
|cat1
|cat2
|cat2
|cat3
|cat3
|cat4
|cat4
}}
}}

Latest revision as of 03:56, 30 January 2025

Summary

Function: integer llModPow( integer a, integer b, integer c );
0.0 Forced Delay
10.0 Energy

Returns an integer that is a raised to the b power, mod c. ( (a**b)%c )

• integer a
• integer b
• integer c

Examples

integer x = llModPow(13743, 14200, 10000); // = 1
integer y = llModPow(0xc734abfa, 0x8371b314, 0xffffffff); // = -1481328730, corresponding to unsigned value of 2813638566

Notes

  • Internally, the parameters are considered unsigned integers. This means it's possible to get extra range by using negative values or hexadecimal, and interpreting the result as such as well.
  • This function used to have a forced delay of 1.0 and precision issues before an update in January 2025.[1]

Deep Notes

Footnotes

Signature

function integer llModPow( integer a, integer b, integer c );