<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Karin,
<br>This is a problem in all floating point operations, namely that you
are trying to represent a base-10 number on base-2 (binary) hardware.
What you see on the screen is java's effort to output the closest decimal
representation to the double or float so
<br>that precision is not lost during I/O. Two common solutions are:
<p> a) The precision
provided is better than what you need. Take what java gives you and round
<br> and/or format
before displaying, printing, or otherwise presenting it to humans.
<br>
<p> b) The precision
provided is not as good as you need. If you're using Java, you can use
<br> BigDecimal to
get arbitrary precision at the cost of performance.
<p>Solution a is sufficient for most, since a Java double provides something
like 16 digits of precision. I forget the
<br>formal definition, but it's something like "The absolute value of the
error will be less than 5 * 10^-17 *
<br>actual result" .
<br>-Jeff
<br>
<p>Karin Faulhaber wrote:
<blockquote TYPE=CITE>Hello,
<p>this is supposed to be simple, maybe I just looked at it for too long:
<br>I have a couple of numbers I want to put into a vtkDataArray (actually
<br>into a vtkPoints object). Let's say the numbers have 5 decimal places
<br>and 7 places (right word??) before the decimal point. For example:
<br>3556236.77071
<p>But with array.GetComponent() I just don't get the same numbers I have
<br>put in.
<p>I played around with doubles and floats and doubleArrays and
<br>floatArrays, I also tried multiplicating with 100000 and casting to
long
<br>ints and so on.
<p>Can someone please point me in the right direction? I should mention
<br>that I use vtk with Java (and obviously hardly have experience with
this
<br>type and casting stuff).
<p>Thanks a lot, this is an important and basic point for me!
<br>Karin
<p>--
<br>Karin Faulhaber
<br>Universitaet Karlsruhe
<br>Institut fuer Photogrammetrie und Fernerkundung (IPF)
<br>Englerstr. 7
<br>76128 Karlsruhe
<p>Tel: 0721/608-3676
<br>E-Mail: faulhaber@ipf.uni-karlsruhe.de
<p>_______________________________________________
<br>This is the private VTK discussion list.
<br>Please keep messages on-topic. Check the FAQ at: <<a href="http://public.kitware.com/cgi-bin/vtkfaq">http://public.kitware.com/cgi-bin/vtkfaq</a>>
<br>Follow this link to subscribe/unsubscribe:
<br><a href="http://public.kitware.com/mailman/listinfo/vtkusers">http://public.kitware.com/mailman/listinfo/vtkusers</a></blockquote>
<pre>--
J.A. Lee</pre>
</html>