vendredi 6 juillet 2018

how to calculate nth root of an integer within a floor function parameter

In C++14 (gcc 6.3) can anyone please explain why floor function returns 6 as the floor value for pow(823543,1.0/7), which is equal to 7, when floor(7) is equal 7

#include <bits/stdc++.h>
using namespace std;

int main() {
    double a=pow(823543,1.0/7);
    cout<<a<<endl<<floor(a);
    return 0;
}

Output:

Success #stdin #stdout 0s 4548KB
7
6

Aucun commentaire:

Enregistrer un commentaire