# Setting range values from random numbers

**URL:** https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175
**Category:** Questions
**Created:** [December 11, 2020, 5:51pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175 "2020-12-11T17:51:26Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Charlie\_Cannon](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/charlie_cannon/32/1708_2.png) [@Charlie\_Cannon](https://cl.desmos.com/u/Charlie_Cannon)
#### Post date: [December 11, 2020, 5:51pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/1 "2020-12-11T17:51:26Z")

</div>

This is what I tried:

r=randomGenerator(button7.pressCount)

a=r.int(-7,7)  
number(`a`):a  
b=r.int(-8,a)

What I want to occur is to create two points whose locations are randomly generated along the x-axis. One point (A) will stay within -7 and 7. I want the other point (B) to have a minimum value of -8 and a max value set by the location of the first point so that its always to the left of A.

---

<div class="post-metadata">

### Author: ![mxepstein](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/mxepstein/32/116_2.png) [@mxepstein](https://cl.desmos.com/u/mxepstein)
#### Post date: [December 11, 2020, 8:17pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/2 "2020-12-11T20:17:03Z")

</div>

Does something like this help?

> **[randomness • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/5fd3d2e1d9ead035a0a2109c)**
>
> by Mx. Epstein

  
I think you solutions works just fine (maybe there a typo related to quotation marks)  
Let me know if I misunderstood you question.

---

<div class="post-metadata">

### Author: ![Charlie\_Cannon](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/charlie_cannon/32/1708_2.png) [@Charlie\_Cannon](https://cl.desmos.com/u/Charlie_Cannon)
#### Post date: [December 11, 2020, 8:26pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/3 "2020-12-11T20:26:49Z")

</div>

That solution worked great! apparently adding the number(‘b’)=b is the thing that needed to happen. Thank you very much.

---

<div class="post-metadata">

### Author: ![Charlie\_Cannon](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/charlie_cannon/32/1708_2.png) [@Charlie\_Cannon](https://cl.desmos.com/u/Charlie_Cannon)
#### Post date: [December 11, 2020, 8:37pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/4 "2020-12-11T20:37:47Z")

</div>

So, maybe we can take this a step further: I am working on an activity for segment addition. So, A and C need to be at the end and B in the middle. This is what I start with:

a=r.int(-7,7)  
b=r.int(-8,a)  
c=r.int(a,7)  
number(`a`):a  
number(`b`):b  
number(`c`):c

This is what I tried and it did not work:  
a=r.int(-7,7)  
b=r.int(-8,a-1)  
c=r.int(a+1,7)  
number(`a`):a  
number(`b`):b  
number(`c`):c

I am fairly certain there is something I need to do but I cannot figure out what. By the way, this is my first week learning CL language so I thank you for your assistance.

---

<div class="post-metadata">

### Author: ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)
#### Post date: [December 12, 2020, 1:17am UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/5 "2020-12-12T01:17:00Z")

</div>

You can’t do operations in CL without using `numericValue`, so replace “a-1” with `numericValue("${a}-1")`. Similar for your “a+1”.

---

<div class="post-metadata">

### Author: ![Charlie\_Cannon](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/charlie_cannon/32/1708_2.png) [@Charlie\_Cannon](https://cl.desmos.com/u/Charlie_Cannon)
#### Post date: [December 14, 2020, 1:14pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/6 "2020-12-14T13:14:24Z")

</div>

> [@Daniel\_Grubbs](#):
>
> numericValue(“${a}-1”)

That works amazingly! Thank you. Is there somewhere in the CL documentation that talks about the use of ${ } that I could read more on? The last couple questions I have had have been answered with this notation.

---

<div class="post-metadata">

### Author: ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)
#### Post date: [December 14, 2020, 6:24pm UTC](https://cl.desmos.com/t/setting-range-values-from-random-numbers/2175/7 "2020-12-14T18:24:04Z")

</div>

Not sure. Use it to call variables into strings, otherwise it will just put the text in. Generally, I think if the variable’s output doesn’t match the input needed, you need to use `${ }`.

> [@Daniel\_Grubbs](#):
>
> numericValue(“${a}-1”)

For example, in the above, `numericValue` takes a string (indicated by the quotes), but “`a`” is a number, so you need to use `${ }`. Without it, it would be undefined because “`a`” is just text. It doesn’t know where to look for the variable without the `${ }`.
