Hello,
I just want to create my core notes but it seems 2 ** 1/12 is not working, equals to -36.37631656250366 according to Sonic Pi. Any idea?
Thank you!
Hello,
I just want to create my core notes but it seems 2 ** 1/12 is not working, equals to -36.37631656250366 according to Sonic Pi. Any idea?
Thank you!
Guessing you want 2 ** (1.0/12)
When working with operators in ruby the left hand side is important. So in the following:
puts 1/2 # outputs 0, left hand side is an Integer so result is also an Integer
puts 1.0/2 # outputs 0.5, left hand side is a Float so result is also a Float
When in doubt you can puts X.class
to see what you’re working with.
And the parens are due to order of operations. **
is quite high so without the parens you get (2 ** 1)/12