0

I've been stuck on this for what feels like hours, but I simply don't understand how to get the pow() function to properly deal with n twelfths of 2

I've tried this

 {
  double base_hz = 440.00;
  base_hz = base_hz / pow(2,(1/ 12));
  printf("HZ is now %f", base_hz);
 }

Which just returns back 440

and I've also tried 440 / pow(2,00.83) which resulted in 247.512863???

1 Answer 1

0

You probably meant 0.083 instead of 00.83, but I totally get what you say.

In C, the division of two integers is an integer (truncating the result). So 1/12 is 0. You could avoid this by making one of them a floating point number, like 1/12.0.

Side note: When you run into the programming language "Python" in pset 6, that used to have the same problem in Python 2, but now, in Python 3, there's the / floating point divide and // integer divide operator. The changes were breaking (and slowly introduced, with a backport to Python 2), this is not going to happen for C.

You must log in to answer this question.