<float>^<float>: Illegal Use of Floating Point

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
raysa
New poster
Posts: 40
Joined: Wed Dec 18, 2002 4:23 pm
Location: Indonesia

<float>^<float>: Illegal Use of Floating Point

Post by raysa »

Hi,

I got the error "Illegal Use of Floating Point" when
I put in a formula like:

Code: Select all

float result = 0.3^0.5;
float result = 0.3^5;
float result = 3^0.5;
I really need to do this kind of calculation but
couldn't figure out what data-type should it take
to proceed a formula in <float>^<float> form.
I've tried float, double, and long double with no success.
I'm sure there must be a way to do the trick.

Thank's in advance,
raysa
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

^ is a bitwise xor operator in C++, and it cannot be applied to floating point types.

If you need exponentiation, use pow(x, y).
For square roots you can use sqrt(x);
raysa
New poster
Posts: 40
Joined: Wed Dec 18, 2002 4:23 pm
Location: Indonesia

Post by raysa »

Solved that way.
Thank you, mf! Really appreciate it.
Post Reply

Return to “C++”