I want to round a number (6.756765345678765) to 10 decimal places , but it returns '6.75677', although it could returns '6.7567653457'
#include <iostream>
#include <cmath>
using namespace std;
double rounded(double number, int N)
{
return round(number * pow(10, N)) / pow(10, N); // i've chanched float to double
}
int main()
{
double value = 6.756765345678765;
cout << rounded(value, 10)
}
I'd like to see a function returns rounded number
Frankly speaking, I'd see an alternative of function 'round' in python
print(round(6.756765345678765, 10))