Page 1 of 1

MLwiN changes numbers

Posted: Wed May 25, 2016 11:13 am
by RasulGro
Hello everyone,

During my work with MLwiN I experienced that the software slightly changed the values for some of my imported variables.
I exported the values from excel. The values are the item averages from various combined item scores on a 5-point Likert scale.
So all values I imported range from 1 to 5.
What MLwiN did is slightly changing the imported values.
For example the orignial value 3.6 became 3.599999905
4.8 became 4.800000191.
I also can confirm that the original values in excel are the exact values and not just a consequence of not displaying enough decimal places.
One could argue that these changes are extremeley small and probably neglectable. Yet I'm interested what happened and how I could prevent MLwiN from changing these numbers.
It also did not happen to all of my variables, just to some of them.

Re: MLwiN changes numbers

Posted: Wed May 25, 2016 11:49 am
by ChrisCharlton
The behaviour that you are seeing is due to MLwiN storing data as single-precision binary floating point numbers (see https://en.wikipedia.org/wiki/IEEE_floating_point). As the elements of this are stored in base-2 there are numbers that can be expressed exactly in base-10 but not here, hence the values that you are seeing. If you reduce the number of decimal places, or change to displaying significant digits (via the Options->Numbers menu) you should see the numbers as you are expecting.

Excel will have similar issues in representing numbers (https://en.wikipedia.org/wiki/Numeric_p ... soft_Excel suggests that it is using double-precision floating point numbers internally), but by default it will round the numbers when displaying them.

Re: MLwiN changes numbers

Posted: Fri Jun 17, 2016 5:34 am
by ghudson621
That is due to the floating point numbers. They put the exact value and not approximate :)