Floats as indices

nnxen (6)
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.
Peter87 (3688)
^ is the bitwise xor operator in C++. Use std::pow in <cmath> instead.
majidkamali1370 (202)
^ is the bitwise xor operator in C++. Use std::pow in <cmath> instead.

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

Thanks, I didn't know that ;)
ne555 (4039)
Also, precedence rules.
hiw (1)
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
Registered users can post here. Sign in or register to post.