Skip to content
lsl.devlsl.devLSL Dev

llModPow

function
Function syntax
integer llModPow(
  1. integer base,// 32-bit unsigned integer base.
  2. integer exponent,// 32-bit unsigned integer exponent.
  3. 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 )

How to use
integer result = llModPow(0, 0, 0);
Example 1
integer x = llModPow(13743, 14200, 10000); // = 1
integer 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.

From the Second Life Wiki

Community documentation adapted from LlModPow, by Linden Research, Inc. and contributing residents.View contributors and history.

Imported wiki revision:

Licensed under CC BY-SA 3.0. Last wiki edit: .Formatting and links have been adapted for this site; API metadata follows the LSL definitions.

  1. Reported , fixed in January 2025: https://feedback.secondlife.com/scripting-bugs/p/getting-wrong-results-from-llmodpow ↩