Guys, I need help
When I compile my code, I get

error: invalid operands to binary ^ (have ‘float’ and ‘double’)

Here's some portion of my code:

#include <stdlib.h>
#include <stdio.h>
...
float freq;
const float key_magic = 2 ^ (1/12);
...
freq=440*(key_magic)^(atof(optarg)-49);

Thanks

Like the error message says, you can only do xor on integers.

Like the error message says, you can only do xor on integers.

Thank you for your response. However, is there any workaround for the problem? I don't really understand about XOR. I know that it is a Logical Operator or sort of but how do I solve this problem?

Use integers.

Or tell us the problem you're really trying to solve, rather than attempting to fix your solution with one line of code.

Use integers.

Or tell us the problem you're really trying to solve, rather than attempting to fix your solution with one line of code.

Actually, I want to generate a sound frequency using the key number. Actually, I could use integer, but then the frequency will loss its accuracy.
Check this link: http://en.wikipedia.org/wiki/Piano_key_frequencies
What I mean is, for example if the input is 49, then it will produce the sound of 440 Hz from the pc speaker. The problem using integer is, for example, if the input is 50, it will produce the sound of 466.164 Hz, which is not an integer, so that's why I can't use integer.

I bet that you want to use power function instead of XOR operator, something like:

#include <math.h>
float key_magic = pow(2., 1./12.);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.