| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
c++ pow() function
hi, i have been having this problem for quite a while now and i still haven't figure it out.
in c++, i tried to compute: #include <math.h> double temp = 2.0; // itried float type too pow( temp, (1/3) ); it returns: 1 when it should really return 1.26 why is it happening? |
|
#2
|
|||
|
|||
|
You're 1/3 will be evaluated as an integer since both parts are integers. So 1/3 actually equals 0 and anything to the power 0 is 1.
Replacing it with 1.0/3.0 should make it work. -KM- |
|
#3
|
|||
|
|||
|
thanks alot
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > c++ pow() function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|