add function round
This commit is contained in:
parent
d12728ddb5
commit
b25b314d2a
@ -10,6 +10,7 @@
|
||||
#include <ios>
|
||||
#include <vector>
|
||||
#include <ranges>
|
||||
#include <cmath>
|
||||
|
||||
namespace ranges = std::ranges;
|
||||
namespace views = std::ranges::views;
|
||||
@ -98,6 +99,14 @@ namespace toolkit
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user