What would be the c++ equivalent for this line of pinescript below?
max := math.max(max, math.abs(series[i]))
What would be the c++ equivalent for this line of pinescript below?
max := math.max(max, math.abs(series[i]))
Code:#include <iostream> #include <vector> #include <algorithm> // max #include <cmath> // abs int main() { std::vector<int> series {-3, 4, 2, -9, 7, -1}; int max = std::abs(series[0]); for (std::size_t i = 1; i < series.size(); ++i) max = std::max(max, std::abs(series[i])); std::cout << max << '\n'; }
A little inaccuracy saves tons of explanation. - H.H. Munro