0

To find root of a no. Using power function !

why we use pow(base, 1.0/order)? i used pow (base, 1/order) but the output every time was 1. so why that .0 thing matters??

25th Jun 2018, 4:47 AM
Bunny
Bunny - avatar
3 odpowiedzi
+ 2
1/order is rounded to 0 since the result must be an int
25th Jun 2018, 5:26 AM
Max
Max - avatar
+ 2
1/order is rounded to 0 if order is an integer, because division of integers is defined this way in the c++ standard. x^0=1 for all x not equal to 0. 1.0/order is rounded to the next floating point number. since x^(1/n) is the nth squareroot of x we get approximately the nth squareroot x
25th Jun 2018, 6:57 AM
Max
Max - avatar
0
please be more precise
25th Jun 2018, 6:49 AM
Bunny
Bunny - avatar