No, this is not the same.
Cast truncations (rounds to zero), the function is floorrounded down.
Demo: http://ideone.com/k8JuA9
#include <iostream>
#include <math.h>
int main()
{
double x = -1.4;
std::cout << "(long long)x = " << ((long long)x) << "\n";
std::cout << "(long long)floor(x) = " << ((long long)floor(x)) << "\n";
return 0;
}
source
share