add function round

This commit is contained in:
Jie 2025-01-07 15:05:57 +08:00
parent d12728ddb5
commit b25b314d2a

View File

@ -10,6 +10,7 @@
#include <ios>
#include <vector>
#include <ranges>
#include <cmath>
namespace ranges = std::ranges;
namespace views = std::ranges::views;
@ -97,6 +98,14 @@ namespace toolkit
{ return T(word.begin(), word.end()); });
return std::vector<T>(v.begin(), v.end());
}
double round(double value, int c){
auto temp = 1;
for(int i=0;i<c;i++){
temp=temp*10;
}
return std::round(value*temp)/temp;
}
}