llModPow
function
Function syntax
integer llModPow(integer base,// 32-bit unsigned integer base.integer exponent,// 32-bit unsigned integer exponent.integer modulus// 32-bit unsigned integer modulus.
);- Returns
integer- Energy
- 10
Returns base raised to the power exponent, modulo modulus (i.e., (b^e)%m). All inputs are wrapped to unsigned 32-bit integer range [0..4294967295]. Output is wrapped to signed 32-bit integer range [-2147483648..2147483647]. Will never overflow, unlike (b^e), which can overflow to inf.
Returns an integer that is a raised to the b power, mod c. ( (a**b)%c )
integer result = llModPow(0, 0, 0);Examples
Section titled “Examples”Example 1
integer x = llModPow(13743, 14200, 10000); // = 1integer y = llModPow(0xc734abfa, 0x8371b314, 0xffffffff); // = -1481328730, corresponding to unsigned value of 2813638566- 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
Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.
Footnotes
Section titled “Footnotes”-
Reported , fixed in January 2025: https://feedback.secondlife.com/scripting-bugs/p/getting-wrong-results-from-llmodpow ↩