# Variable length limits?

**URL:** <https://forum.choiceofgames.com/t/variable-length-limits/162624>\
**Category:** ChoiceScript Help\
**Created:** [December 12, 2024, 12:38am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624 "2024-12-12T00:38:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cultivator-anon](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cultivator-anon/32/218353_2.png) [@cultivator-anon](https://forum.choiceofgames.com/u/cultivator-anon)\
**Post date:** [December 12, 2024, 12:38am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/1 "2024-12-12T00:38:39Z")

</div>

I’m using large variables to keep track of a lot of information. I started with 11-digit variables and it worked fine, but now that I just tried a 40 digit variable to record wardrobes and call them with `{wardrobe#30}` or somesuch, I’ve run into an error where Randomtest and maybe ChoiceScript itself converts my variable. What was once just a long number, allowing me to call each digit to check if a binary flag was switched, now is converted into a shortened version like “1.0000000001000101e+40”

Naturally, this is a problem. Calling `{wardrobe#20}` or so snags the e instead of a 0 or 1, and it shortened the variable so calling `{wardrobe#40}` fails. Does anyone know the digit limit before choicescript converts a variable, and if that can be fixed in a patch?

I can and will be coding around it, but felt it should be brought up.

---

<div class="post-metadata">

**Author:** ![Loudbeat](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/loudbeat/32/115975_2.png) [@Loudbeat](https://forum.choiceofgames.com/u/Loudbeat)\
**Post date:** [December 12, 2024, 12:44am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/2 "2024-12-12T00:44:45Z")

</div>

It shouldn’t be a limit for numeric variables. However, that doesn’t mean it’s stored as a binary. What you’re trying to do works well for numbers not that long. If you want to store 40+ bits I would suggest doing so in another way.

> **[Data types](https://choicescriptdev.fandom.com/wiki/Data_types#Numeric_data_limitations)**
>
>       This article is aimed at beginners to ChoiceScript. However, if you have not already done so then the best place to start would be with the very first article in this Introduction To ChoiceScript Game Development series of linked...

---

<div class="post-metadata">

**Author:** ![cultivator-anon](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cultivator-anon/32/218353_2.png) [@cultivator-anon](https://forum.choiceofgames.com/u/cultivator-anon)\
**Post date:** [December 12, 2024, 1:10am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/3 "2024-12-12T01:10:35Z")

</div>

For anyone wondering, finally finished checking and the limit is 21 digits before the code starts converting it to something else like `1.0001000001000102e+21`

---

<div class="post-metadata">

**Author:** ![Valda\_Reehux](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/valda_reehux/32/126891_2.png) [@Valda\_Reehux](https://forum.choiceofgames.com/u/Valda_Reehux)\
**Post date:** [December 12, 2024, 1:33am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/4 "2024-12-12T01:33:21Z")

</div>

I don’t think there is a length limit for variable, because we never have to declare its length when creating the variable itself

I once created a variable that stores an entire inventory, which around 120 digits ( 4 item ID length x 30 slots )

and it was not a **create\_array inventory 30** , it was **create inventory** , just a single variable storing 120 digits of item IDs

---

<div class="post-metadata">

**Author:** ![cup\_half\_empty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cup_half_empty/32/273983_2.png) [@cup\_half\_empty](https://forum.choiceofgames.com/u/cup_half_empty)\
**Post date:** [December 12, 2024, 2:23am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/5 "2024-12-12T02:23:54Z")

</div>

You should use a string instead of a number.

---

<div class="post-metadata">

**Author:** ![the.normandy](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/the.normandy/32/243723_2.png) [@the.normandy](https://forum.choiceofgames.com/u/the.normandy)\
**Post date:** [December 12, 2024, 5:24am UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/6 "2024-12-12T05:24:03Z")

</div>

It’s less a ChoiceScript thing and more a JavaScript thing. That’s a thing that JavaScript does with integers at that size.

There are ways to parse this number if you really want, but it’ll be messy and likely involve \*script calling functions written in JS

---

<div class="post-metadata">

**Author:** ![Nahim\_Kerman](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/nahim_kerman/32/62734_2.png) [@Nahim\_Kerman](https://forum.choiceofgames.com/u/Nahim_Kerman)\
**Post date:** [December 12, 2024, 9:28pm UTC](https://forum.choiceofgames.com/t/variable-length-limits/162624/7 "2024-12-12T21:28:39Z")

</div>

I may be wrong but I believe cup\_half\_empty solution will solve your Issue. Just Declare your datatype as string and avert using operations that may cause the intrepeter to think you are dealing with numbers rather than chars.

Or, you can download one of the other [user made solutions](https://forum.choiceofgames.com/t/algorithm-hall-of-fame-and-code-examples-sorting-shuffling-dev-tools/94552)…
