# I want to make a triplet

**URL:** <https://in-thread.sonic-pi.net/t/i-want-to-make-a-triplet/5650>\
**Category:** Support, Help & Resources\
**Created:** [May 29, 2021, 4:33am UTC](https://in-thread.sonic-pi.net/t/i-want-to-make-a-triplet/5650 "2021-05-29T04:33:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyeroni](https://avatars.discourse-cdn.com/v4/letter/h/d07c76/32.png) [@hyeroni](https://in-thread.sonic-pi.net/u/hyeroni)\
**Post date:** [May 29, 2021, 4:33am UTC](https://in-thread.sonic-pi.net/t/i-want-to-make-a-triplet/5650/1 "2021-05-29T04:33:34Z")

</div>

Hello.  
I was trying to make a triplet rhythm, but when I do the following, I got an error.  
What should I do?

t = 1  
loop do  
use\_synth :pretty\_bell  
play 70  
sleep t/3  
end

---

<div class="post-metadata">

**Author:** ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)\
**Post date:** [May 29, 2021, 4:57am UTC](https://in-thread.sonic-pi.net/t/i-want-to-make-a-triplet/5650/2 "2021-05-29T04:57:39Z")

</div>

Hello @hyeroni 🙂  
The Ruby language (and by extension, Sonic Pi, which is based on it) is in this case treating the value of `t/3` as an integer, since both `t` and `3` are integers - therefore, instead of something like `0.3`, (to however many decimal places) it is treating the result as `0`.

Since an integer result (which in this results in dividing by zero) is not what you want, the solution here is to cause Ruby/Sonic Pi to give you a floating point number answer instead. You do this by making sure that at least one of the numbers in the division is a floating point number, which you can do by writing something like this: `t/3.0`. (note the decimal point and zero), or you could also convert `t` to a float by saying something like `t.to_f/3` 🙂

---

<div class="post-metadata">

**Author:** ![gregeporter](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/gregeporter/32/1277_2.png) [@gregeporter](https://in-thread.sonic-pi.net/u/gregeporter)\
**Post date:** [May 30, 2021, 1:22am UTC](https://in-thread.sonic-pi.net/t/i-want-to-make-a-triplet/5650/3 "2021-05-30T01:22:04Z")

</div>

What an interesting quirk of the language and a good fix. I’m inclined to go with making it 3.0

---

<div class="post-metadata">

**Author:** ![hyeroni](https://avatars.discourse-cdn.com/v4/letter/h/d07c76/32.png) [@hyeroni](https://in-thread.sonic-pi.net/u/hyeroni)\
**Post date:** [May 31, 2021, 12:58am UTC](https://in-thread.sonic-pi.net/t/i-want-to-make-a-triplet/5650/4 "2021-05-31T00:58:47Z")

</div>

Thank you so much~~ ^^\*
