# Negative Number Issues

**URL:** <https://forum.choiceofgames.com/t/negative-number-issues/2139>\
**Category:** ChoiceScript Help\
**Created:** [February 20, 2014, 6:02pm UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139 "2014-02-20T18:02:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![stainedofmind](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stainedofmind/32/459_2.png) [@stainedofmind](https://forum.choiceofgames.com/u/stainedofmind)\
**Post date:** [February 20, 2014, 6:02pm UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/1 "2014-02-20T18:02:37Z")

</div>

While I was working on my stats page, I came across a few issues with negative numbers. I’m uncertain if I’m doing something wrong or if the problem lies in ChoiceScript itself.

First off, in my startup scene, I am unable to create variables with default values below zero. For example, the following line of code:

\*create pc\_arcana -1

… Results in the following error:

“Invalid create instruction, value must be a a number, true/false, or a quoted string: pc\_arcana -1”

Secondly, I am unable to use negative values in conditional statements, for example:

\*if (pc\_arcana = -1)

… Results in the error:

“Invalid expression at char 14, expected NUMBER, STRING, VAR or PARENTHETICAL, was: OPERATOR ”

I was able to circumvent both issues, but in both cases, they are less then satisfactory solutions. Any guidance is much appreciated, and thanks in advance!

---

<div class="post-metadata">

**Author:** ![Samuel\_H\_Young](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/samuel_h_young/32/275971_2.png) [@Samuel\_H\_Young](https://forum.choiceofgames.com/u/Samuel_H_Young)\
**Post date:** [February 20, 2014, 6:10pm UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/2 "2014-02-20T18:10:20Z")

</div>

Sadly, CS doesn’t register negative numbers, so you’ll have to find some way around it.

---

<div class="post-metadata">

**Author:** ![stainedofmind](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stainedofmind/32/459_2.png) [@stainedofmind](https://forum.choiceofgames.com/u/stainedofmind)\
**Post date:** [February 20, 2014, 6:19pm UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/3 "2014-02-20T18:19:52Z")

</div>

Inconvenient. I’m not planning on any extensive use of negatives however, so I will live. Thanks for the heads up!

---

<div class="post-metadata">

**Author:** ![Samuel\_H\_Young](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/samuel_h_young/32/275971_2.png) [@Samuel\_H\_Young](https://forum.choiceofgames.com/u/Samuel_H_Young)\
**Post date:** [February 20, 2014, 6:54pm UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/4 "2014-02-20T18:54:23Z")

</div>

Np, man.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [February 20, 2014, 11:24pm UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/5 "2014-02-20T23:24:10Z")

</div>

My first ever post to the forum was this very question: [http://www.choiceofgames.com/forum/discussion/204/negative-stats#Item\_4](http://www.choiceofgames.com/forum/discussion/204/negative-stats#Item_4)

---

<div class="post-metadata">

**Author:** ![stainedofmind](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stainedofmind/32/459_2.png) [@stainedofmind](https://forum.choiceofgames.com/u/stainedofmind)\
**Post date:** [February 21, 2014, 6:11am UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/6 "2014-02-21T06:11:04Z")

</div>

My solution for conditionals was to do something like this:

\*if ((pc\_arcana + 1) = 0)

… Which is checking to see if pc\_arcana = -1 in reality. Unfortunately, for creating variables, one has to set their value after creation.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [February 21, 2014, 6:30am UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/7 "2014-02-21T06:30:33Z")

</div>

Yeah - I think that’s unlikely to work well for most uses of variables, and so re-centering on (say) 50 rather than 0 is a more promising approach.

Of course it is still possible to have and use negative variables - for example, you can create a variable at 0 and then set it minus 1000. You just can’t create it as a negative number in the first place, or use it in conditional statements more precise than “\*if stat \< 0” (without elaborate addition setups like yours). In CoReb I’ve got several stats where you get a different effect when you go negative.

---

<div class="post-metadata">

**Author:** ![stainedofmind](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/stainedofmind/32/459_2.png) [@stainedofmind](https://forum.choiceofgames.com/u/stainedofmind)\
**Post date:** [February 21, 2014, 8:11am UTC](https://forum.choiceofgames.com/t/negative-number-issues/2139/8 "2014-02-21T08:11:55Z")

</div>

Yeah, definitely cumbersome. Luckily, I just need it as a flag to indicate the inability to use said stat. I suppose I could have just created a boolean, but oh well. I hate being a programmer sometimes 😛
