1,105,310 Community Members

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

Member Avatar
vineeshvs
Light Poster
46 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
double a,b;
printf("%f",a^b);

error occurs as shown in heading.
any alternative method?

Member Avatar
Narue
Bad Cop
12,139 posts since Sep 2004
Reputation Points: 5,693 [?]
Q&As Helped to Solve: 1,537 [?]
Skill Endorsements: 80 [?]
Team Colleague
 
1
 

Before looking for ways to do this, maybe you should consider why you want to do it in the first place. Bitwise operations not working on floating-point isn't much of an issue because most of the time it's nonsensical.

Member Avatar
vineeshvs
Light Poster
46 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

by a^b i mean 'a raised to b' (bth power of a). not bitwise operations.

Member Avatar
WaltP
Posting Sage w/ dash of thyme
9,363 posts since May 2006
Reputation Points: 2,905 [?]
Q&As Helped to Solve: 1,151 [?]
Skill Endorsements: 45 [?]
Team Colleague
 
1
 

Where you got the idea ^ means raised to the power in C is a great question.

Belaying that, look in the math.h header for the function pow()

Member Avatar
vineeshvs
Light Poster
46 posts since Jan 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thanks... i was converting matlab to c. so didnt notice...

Question Answered as of 3 Years Ago by Narue and WaltP
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: