Answer the question
In order to leave comments, you need to log in
Loss of precision in type conversion?
Here is such a function:
void fp()
{
int64_t tmpn=(((1<<30)-1)/3*2)*1000LL;
double tmpd=tmpn/1000.0;
int64_t tmpm=(int64_t)(tmpd*1000.0);
printf("%lld %.3f %lld\n", tmpn, tmpd, tmpm);
fflush(stdout);
}
715827882000 715827882.000 715827882000
715827882000 715827904.000 715827904512
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question