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.
精彩评论