ai lian wrote:
>
> When I use printf to print a large double number, the result is not
> the same as the original input number. For example:
>
> double num=899999999999.894400;
> printf("%lf\n",num);
>
> The output is: 899999999999.894409
>
> Could anyone tell me what the problem is? How can I get the right
> output?
Question 14.1 in the comp.lang.c Frequently Asked
Questions (FAQ) list
http://www.eskimo.com/~scs/C-faq/top.html
covers part of your problem. The rest is due to unrealistic
expectations: Why do you think you're going to get accuracy
to eighteen (or more!) significant digits? The C language
Standard only promises ten and you're actually getting
fifteen, so what are you complaining about?
--