开发者

Why aren't my "double" values printed the way I expected them? [closed]

开发者 https://www.devze.com 2023-02-14 19:36 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying t开发者_运维知识库his question so that it can be reopened, visit the help center. Closed 11 years ago.

Can I represent the following co-ordinate triplets using variable type "double"?

512685.93 5403444.22 305.63, 
512685.91 5403445.72 305.55,
512685.90 5403447.12 305.54, ... 

Those values correspond to x, y & z in my input file. After doing some process by my program, I got the output file with following values as:

512668 5.40345e+006 321.39, 
512667 5.40345e+006 321.57, 
512666 5.40345e+006 321.89, 
512666 5.40344e+006 321.32, 
512665 5.40344e+006 321.64, ...

I have used double x, y, z to represent those values. Why aren't they printed with a format more similar to the first example?


Can you? Well, yes, if you can live with the inherent inexactness in all floating point computations.

Of course, there's not enough detail in your question to determine whether your problems are due to roundoff, or due to some error in your program, or even if there is a problem in the first place!


Look at how you print the values, likely the values are still fine but your output mechanism limits precision.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号