# llIntegerToBase64

*LSL function*

```lsl
string string llIntegerToBase64(integer number);
```

- `integer number`: Integer number to encode.

- Returns: `string`
- Energy: 10

Returns an 8-character Base64 string representing the big-endian encoded value of number.

Returns a [string](https://wiki.secondlife.com/wiki/string) that is a [Base64](https://wiki.secondlife.com/wiki/Category:LSL_Base64) big endian encode of **number**

```lsl title="How to use" frame="terminal"
string result = llIntegerToBase64(0);
```

## Examples

<details open>
<summary>Example 1</summary>

```lsl
string ASCII7ToString(integer letter)
{
    if(letter >= 0x80 || letter < 0) return "";//Not valid ascii7 character
    return llBase64ToString(llIntegerToBase64(letter << 24));
}
```

</details>

<details>
<summary>Example 2</summary>

```lsl
// Packs a 24-bit unsigned integer value (0-16777215) to only 4 Base64 characters.
string Int24ToBase64(integer value)
{
    return llGetSubString(llIntegerToBase64(value<<8), 0, 3);
}
// unpacks a 4-character Base64 value to a 24-bit unsigned integer
integer Base64ToInt24(string value)
{
    return (llBase64ToInteger(value)>>8)&0xffffff; // Masking required to remove sign extension from bit-shifting
}
```

</details>

If you are looking for full Unicode translation, not just ASCII7 see: [Combined_Library](https://wiki.secondlife.com/wiki/Combined_Library#unicode-integer-to-utf8)

## Notes

- Only the first 6 of the 8 characters returned are needed to decoded it back into an integer. The padding "==" can be safely removed for storage.
- "Big-endian" refers to the fact that the most significant, i.e. highest byte of the integer is processed first: the first characters in the returned Base64 string correspond to this byte, and the last characters correspond to the least significant byte.
- Combined with bit-shifting, removing characters from the Base64 string allows more efficient packing of small values. See [llBase64ToInteger caveats](/functions/llBase64ToInteger/#caveats) for specifics.

## See also

### Functions

- [llBase64ToInteger](/functions/llBase64ToInteger/)
- [llBase64ToString](/functions/llBase64ToString/)
- [llStringToBase64](/functions/llStringToBase64/)

---

*Source: [LlIntegerToBase64](https://wiki.secondlife.com/wiki/LlIntegerToBase64) on the Second Life Wiki. Content from the Second Life Wiki article LlIntegerToBase64 (revision 1215002, 2023-10-11), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llIntegerToBase64/
