When I multiply a long long
value with a double
value, I get a double
value.
To convert it back to long long
, I use (long long)
.
But the output I get is 0
, when it should be 10
.
This is my code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n = 100;
printf("%lld",(long long)0.1*n);
return 0;
}
Why is this? How can I fix this?