biolab / orange2

DEPRECATED: Orange 2 (Python 2) data mining suite. NEW: https://github.com/biolab/orange3
GNU General Public License v3.0
308 stars 142 forks source link

value conversion bug for relatively large numbers #57

Open wenchenvincent opened 6 years ago

wenchenvincent commented 6 years ago

I was trying to create data tables from Python list of list. I found that there was a problem with importing the values correctly for some relatively large numbers. It seemed that there was bug when creating a Continunous Value with relatively large numbers. For example

Orange.data.Value(Orange.feature.Continuous(),308632021)

This construction will give me the following Value: <orange.Value ''='308632032.000'>

It seems that for relatively large numbers, the conversion would usually be wrong but in a way that is not like an overflow.

ales-erjavec commented 6 years ago

The values are stored as 32-bit floats internally. They have precision of 24 significant bits meaning they cannot (generally) represent integer values larger then 16777216.

For instance this will fail at the last line

 assert np.float32(2 ** 24 - 1) == 2 ** 24 - 1
 assert np.float32(2 ** 24 ) == 2 ** 24
 assert np.float32(2 ** 24 + 1 ) == 2 ** 24 + 1
wenchenvincent commented 6 years ago

Thank you for the answer! Is there any option that we can choose to represent the numbers as double precision?

ales-erjavec commented 6 years ago

I am afraid not.