Floats as indices

I'm having a problem with the following calculation in a line of code:

10^(dB/20)

...where dB is a float. I get Error: Expression must have integral or enum type.

How can I get around this?
Thanks in advance.
^ is the bitwise xor operator in C++. Use std::pow in <cmath> instead.
^ is the bitwise xor operator in C++. Use std::pow in <cmath> instead.

Or you can overload that operator, while this is not recommended.
You aren't allowed to overload operators to where both operands are primitive types.
You should put
dB/20
into a temp variable.
int temp = dB/20;
... = 10 ^ temp;
Last edited on
You aren't allowed to overload operators to where both operands are primitive types.

Thanks, I didn't know that ;)
Also, precedence rules.
You aren't allowed to overload operators to where both operands are primitive types.

for majidkamali 1370

Actually, it is useless when both operands are primitive types
Topic archived. No new replies allowed.