[ create a new paste ] login | about

Link: http://codepad.org/5OxZn9KT    [ raw code | output | fork ]

fisherro - C++, pasted on Aug 13:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <vector>
#include <iostream>
#include <numeric>

//Always make sure the third parameter to std::accumulate is the right type.
int main()
{
    const uint64_t n(0x0F0000000);
    std::vector<uint64_t> v;
    v.push_back(n);
    v.push_back(n);
    std::cout << (n + n) << '\n';
    std::cout << std::accumulate(v.begin(), v.end(), 0) << '\n';
    std::cout << std::accumulate(v.begin(), v.end(), static_cast<uint64_t>(0)) << '\n';
}


Output:
1
2
3
8053063680
-536870912
8053063680


Create a new paste based on this one


Comments: