Why do these two multiplication operations give different results?

long oneYearWithL = 1000*60*60*24*365L; long oneYearWithoutL = 1000*60*60*24*365; Your first value is actually a long (Since 365L is a long, and 1000*60*60*24 is an integer, so the result of multiplying a long value with an integer value is a long value. But 2nd value is an integer (Since you are mulitplying an integer value with … Read more

PostgreSQL – IN vs ANY

No, in these variants are same: You can see – the execution plans are same too: postgres=# explain select * from foo1 where id in (select id from foo2); ┌──────────────────────────────────────────────────────────────────┐ │ QUERY PLAN │ ╞══════════════════════════════════════════════════════════════════╡ │ Hash Semi Join (cost=3.25..21.99 rows=100 width=4) │ │ Hash Cond: (foo1.id = foo2.id) │ │ -> Seq Scan on … Read more

Multiply vector elements by a scalar value using STL

Yes, using std::transform: std::transform(myv1.begin(), myv1.end(), myv1.begin(), std::bind(std::multiplies<T>(), std::placeholders::_1, 3)); Before C++17 you could use std::bind1st(), which was deprecated in C++11. std::transform(myv1.begin(), myv1.end(), myv1.begin(), std::bind1st(std::multiplies<T>(), 3)); For the placeholders; #include <functional>

tech