REBOL3 tracker
  0.9.12 beta
Ticket #0001633 User: anonymous

Project:



rss
TypeBug Statusbuilt Date14-Jul-2010 23:19
Versionalpha 58 CategoryNative Submitted byabolka
PlatformLinux x86 libc6 Severityminor Prioritynormal

Summary Fix inconsistency of mold/all of decimals between Linux x86 and OSX/Win32
Description (Originally "mold/all 0.1 on Windows and Linux produces a different result". Updated to reflect the comments.)

The results of mold/all for decimals on Linux is inconsistent with other platforms (Win32, OSX):

>> mold/all 0.3
== "0.3" ; expected: "0.29999999999999999"

>> mold/all 0.1
== "0.1" ; expected: "0.10000000000000001"

Basically this is #897 re-opened as it was never really fixed on Linux. See the comments for a suggested fix by Ladislav.
Example code

			

Assigned ton/a Fixed inr3 master Last Update21-Jan-2013 06:56


Comments
(0002445)
Carl
15-Jul-2010 00:02

We work to try to avoid issues like that, but it is not easy because there are subtle differences in the implementation of the standard C math lib between platforms, and also the availability and definition of fundamental lower level lib functions (like gcvt()). Such things will pop up, and we need to fix them.
(0002881)
PeterWood
16-Nov-2010 00:54

Also on OS X


>> system/version
== 2.100.109.2.5

>> mold/all 0.1
== "0.10000000000000001"
(0002884)
Ladislav
17-Nov-2010 11:47

The expression result is obtained as a result of two operations:

*the first one is LOAD function transforming the "0.1" part of the input string to a 64-bit binary IEEE754 number used as the internal representation of REBOL decimals. In accordance with the standard, the result of this operation is exactly

0.1000000000000000055511151231257827021181583404541015625

*the second operation is MOLD/ALL, transforming the above number to string.

Both "0.1" as well as "0.10000000000000001" are results that are accurate enough from the POV that the expressions

zero? 0.1 - load string
same? 0.1 load string

both yield TRUE. The difference is that the Windows ECVT version yields the string containing exactly 17 digits of the floating point number while the Linux version of ECVT yields the minimal string that represents the number accurately enough, i.e., in such a way that the two tests mentioned above both yield TRUE.
(0002887)
Ladislav
18-Nov-2010 08:20

In the core-tests suite. (the core-tests suite currently tests the accuracy of the MOLD/ALL result)

To obtain the same string on all platforms it probably is best to use the code available, e.g., from

https://github.com/android/platform_bionic/blob/master/libc/stdlib/strtod.c

, on the platforms offering only a less convenient alternative of the behaviour.
(0003124)
abolka
22-Feb-2011 01:02

Still not fixed in A111:

>> system/version
== 2.100.111.4.4

>> mold/all 0.3
== "0.3"

>> mold/all 0.1
== "0.1"
(0003129)
abolka
26-Feb-2011 16:18

HAS_ECVT is still defined (for TO_LINUX) in the hostkit sources.
(0003261)
abolka
13-Dec-2012 02:26

*Not* fixed in the 101.0 (08eb7e84cd) open source release.

HAS_ECVT is still defined. Undefining it, fixes the immediate issue while not introducing any regression in the rebol-test suite.
(0003264)
abolka
14-Dec-2012 01:54

(I submitted removing HAS_ECVT as https://github.com/rebol/r3/pull/4.)

Unfortunately, without HAS_ECVT `mold/all 0.1` works as expected, this comes at the expense of a regression. Without `HAS_ECVT` the following fails in Linux builds:

same? 9.9999999999999926e154% load mold/all 9.9999999999999926e154%

Whereas with `HAS_ECVT` for Linux the above is true as it already is on Win32, OSX.
(0003272)
abolka
17-Dec-2012 00:27

Works with Carl's merge in b064f51eb180ff50e74ba815d780001fc2120694.
(0003387)
Ladislav
21-Jan-2013 03:12

This is a related but separate issue than #897. Also, we need to have a more general solution working for R3/Droid and Linux/ARM, not just for Linux/X86, I will open a new ticket for those.

Date User Field Action Change
21-Jan-2013 06:56 abolka Summary Modified Fix string output inconsistency of mold/all of decimals on Linux x86 => Fix inconsistency of mold/all of decimals between Linux x86 and OSX/Win32
21-Jan-2013 03:15 Ladislav Comment : 0003387 Modified -
21-Jan-2013 03:14 Ladislav Comment : 0003387 Modified -
21-Jan-2013 03:12 Ladislav Comment : 0003387 Added -
21-Jan-2013 03:10 Ladislav Comment : 0002884 Modified -
21-Jan-2013 03:09 Ladislav Comment : 0002884 Modified -
20-Jan-2013 03:29 abolka Status Modified complete => built
20-Jan-2013 03:28 abolka Fixedin Modified 2.101.0 => r3 master
20-Jan-2013 02:12 abolka Summary Modified Fix cross-platform inconsistency of mold/all of decimals on Linux x86 => Fix string output inconsistency of mold/all of decimals on Linux x86
20-Jan-2013 02:10 abolka Summary Modified Fix mold/all of decimals on Linux => Fix cross-platform inconsistency of mold/all of decimals on Linux x86
20-Jan-2013 01:49 Ladislav Comment : 0003271 Removed -
20-Jan-2013 01:47 Ladislav Comment : 0003128 Removed -
20-Jan-2013 01:47 Ladislav Comment : 0002887 Modified -
20-Jan-2013 01:46 Ladislav Comment : 0002887 Modified -
20-Jan-2013 01:33 Ladislav Comment : 0002885 Removed -
20-Jan-2013 01:32 Ladislav Comment : 0002884 Modified -
17-Dec-2012 00:28 abolka Status Modified submitted => complete
17-Dec-2012 00:28 abolka Fixedin Modified => 2.101.0
17-Dec-2012 00:27 abolka Comment : 0003272 Added -
16-Dec-2012 23:33 Ladislav Comment : 0003271 Added -
14-Dec-2012 01:54 abolka Comment : 0003264 Added -
13-Dec-2012 02:26 abolka Comment : 0003261 Added -
26-Feb-2011 16:18 abolka Comment : 0003129 Added -
26-Feb-2011 14:23 Ladislav Comment : 0003128 Added -
23-Feb-2011 23:53 BrianH Category Modified Unspecified => Native
22-Feb-2011 05:54 abolka Status Modified complete => submitted
22-Feb-2011 05:54 abolka Fixedin Modified alpha 111 => none
22-Feb-2011 05:54 abolka Comment : 0003124 Modified -
22-Feb-2011 01:02 abolka Status Modified built => complete
22-Feb-2011 01:02 abolka Comment : 0003124 Added -
21-Nov-2010 20:43 carl Status Modified pending => built
21-Nov-2010 20:43 carl Fixedin Modified => alpha 111
18-Nov-2010 08:20 Ladislav Comment : 0002887 Added -
17-Nov-2010 23:22 abolka Summary Modified Properly mold/all decimals on Linux => Fix mold/all of decimals on Linux
17-Nov-2010 23:20 abolka Platform Modified All => Linux x86 libc6
17-Nov-2010 23:20 abolka Status Modified reviewed => pending
17-Nov-2010 23:20 abolka Version Modified alpha 99 => alpha 58
17-Nov-2010 23:20 abolka Description Modified -
17-Nov-2010 23:20 abolka Summary Modified mold/all 0.1 on Windows and Linux produces a different result => Properly mold/all decimals on Linux
17-Nov-2010 21:15 Ladislav Comment : 0002885 Modified -
17-Nov-2010 21:13 Ladislav Comment : 0002885 Added -
17-Nov-2010 14:11 Ladislav Comment : 0002884 Modified -
17-Nov-2010 14:00 Ladislav Comment : 0002884 Modified -
17-Nov-2010 13:59 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:17 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:16 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:12 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:11 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:10 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:09 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:08 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:05 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:04 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:02 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:00 Ladislav Comment : 0002884 Modified -
17-Nov-2010 12:00 Ladislav Comment : 0002884 Modified -
17-Nov-2010 11:56 Ladislav Comment : 0002884 Modified -
17-Nov-2010 11:52 Ladislav Comment : 0002884 Modified -
17-Nov-2010 11:51 Ladislav Comment : 0002884 Modified -
17-Nov-2010 11:47 Ladislav Comment : 0002884 Added -
16-Nov-2010 00:54 PeterWood Comment : 0002881 Added -
15-Jul-2010 00:02 carl Comment : 0002445 Added -
14-Jul-2010 23:59 carl Status Modified submitted => reviewed
14-Jul-2010 23:59 carl Description Modified -
14-Jul-2010 23:19 abolka Ticket Added -