# How do I have random generator use mixed numbers?

**URL:** <https://cl.desmos.com/t/how-do-i-have-random-generator-use-mixed-numbers/7305>\
**Category:** Questions\
**Created:** [September 23, 2024, 12:44pm UTC](https://cl.desmos.com/t/how-do-i-have-random-generator-use-mixed-numbers/7305 "2024-09-23T12:44:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bonnie\_Gauselman](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bonnie_gauselman/32/6026_2.png) [@Bonnie\_Gauselman](https://cl.desmos.com/u/Bonnie_Gauselman)\
**Post date:** [September 23, 2024, 12:44pm UTC](https://cl.desmos.com/t/how-do-i-have-random-generator-use-mixed-numbers/7305/1 "2024-09-23T12:44:38Z")

</div>

I looked on YouTube and was able to figure out how to create problems with the random generator, but I cannot figure out how to get it to use mixed numbers. How can I do this? This is the code I am using:

r = randomGenerator(refresh1.pressCount)

addend1 = r.int(0,100)  
addend2 = r.int(0,100)

sum = numericValue(“{addend1}+{addend2}”)

numberList(`C_{orrectnessHistory}`): mathinput1.history(“correct”)

---

<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:** [September 23, 2024, 2:57pm UTC](https://cl.desmos.com/t/how-do-i-have-random-generator-use-mixed-numbers/7305/2 "2024-09-23T14:57:22Z")

</div>

Instead of `.int()` you can use `.float()` to get decimal values to 15 places. You could round them using numericValue.

```auto
addend1 = numericValue(`\round(${r.float(0,100)},2)`)

```

If you’re looking to display a mixed number, you’d need to randomly generate each part of the mixed number separately.

```auto
r = randomGenerator()

denom0 = r.int(2,10)
numerator0 = r.int(1,numericValue(`${denom0}-1`))
gcf = numericValue(`\gcf(${denom0},${numerator0})`)

#use below for simplified fractions
denom = numericValue(`${denom0}/${gcf}`)
numer = numericValue(`${numerator0}/${gcf}`)
whole = r.int(1,10)

fracLatex = `${whole}\frac{${numer}}{${denom}}`

```
