How to make power for fraction in C++?

Status
Not open for further replies.

fatma1000

Banned
Joined
Apr 30, 2006
Messages
147
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
eygpt
Activity points
0
help12 c++

the function pow like
pow(2,4)

is correct but whin the first number is fraction like

pow(0.5,4)

it is not correct why?

how can i make power for fraction like (0.5) powered to 4
0.5*0.5*0.5*0.5

regards
 

help12 c++

if my long forgotten maths serves me here:

pow(0.5,4) = 1/pow(2,4)
 

Re: help12 c++

The above method works but only for fractions less than 1. You can use the above and the pow(x,y) function in a recursive loop to solve the problem.

Cheers
Slayer
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…