Orange Forum • View topic - loss of precision when reading float values

loss of precision when reading float values

Report bugs (or imagined bugs).
(Archived/read-only, please use our ticketing system for reporting bugs and their discussion.)
Forum rules
Archived/read-only, please use our ticketing system for reporting bugs and their discussion.

loss of precision when reading float values

Postby chrismurphy » Wed Mar 22, 2006 22:17

I imagine this must have been reported before, but I am losing precision in some float values when using the out-of-the-box tools for reading files.

For instance, I have a tab-delimited file numbers.tab that looks something like this:

first second third fourth
c c c discrete
class
0.3423525 24.34254646 44.5346436 yes


And I load it using this code:
Code: Select all
data = orange.ExampleTable("numbers.tab")


Then I want to just look at it, like this:
Code: Select all
for i in range(len(data)):
      print data[i]

However, this is what I get:
[0.34235251, 24.34254646, 44.5346451, 'yes']

The errors are slight, but still there. I have observed this with other file loaders (including one I wrote myself) and see it consistently on both XP with the 0.9.62 binary distribution and on Linux with a code snapshot that we built ourselves.

Anyone ever run into this?

Postby Janez » Wed Mar 22, 2006 22:40

It's rounding error: Orange stores number as C++ floats (except in some numerically critical places, where it internally uses doubles). We considered going to doubles, but seven decimal places should be more than enough for the usual machine learning needs.

Try your numbers at http://www.h-schmidt.net/FloatApplet/IEEE754.html - it gives exactly the rounding errors from your post.


Return to Bugs



cron