View Issue Details

IDProjectCategoryView StatusLast Update
0000821LDMud 3.5Portabilitypublic2013-08-18 22:43
ReporterLeonidas Assigned Tozesstra  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionno change required 
Summary0000821: Floating point handling on Cygwin seems to be broken somehow
DescriptionTests of 32 bit installation on two up-to-date (CYGWIN_NT-6.1-WOW64 1.7.20(0.266/5/3)) cygwin-installations showed json_serialize() and printf() (suggestion of Zesstra) for big floating point broken. Successful test on a 3.5.0-23 32bit-Linux showed that error seems to be limited to Cygwin-installations.

Results:

xeval __FLOAT_MAX__
32 Cygwin/64 (Morgengrauen): 1.79769e+308

xeval printf("%f", __FLOAT_MAX__) on 32 Cygwin gives:
"1797689999862523788533120072154799163534555000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000"

xeval printf("%f", __FLOAT_MAX__) on 64 gives:
"1797690000000000063230304921389426434930330364336853362154109832891264341489062
8994061529963219660944553381632031277443348485990004649114105165109167273447097
2759941382582304802812882753059262973637182942535982636884444611376868582636745
405553206881859340916340092953230149901406738427651121855107737424232448"

xeval json_serialize(__FLOAT_MAX__) on 32 Cygwin gives:
"179768999986252378853312007215479916353455500000000000000000000000000000000000
0000000000000000000000000000000000000000000000000"

xeval json_serialize(__FLOAT_MAX__) on 64 gives:
"179769000000000006323030492138942643493033036433685336215410983289126434148906
2899406152996321966094455338163203127744334848599000464911410516510916727344709
7275994138258230480281288275305926297363718294253598263688444461137686858263674
5405553206881859340916340092953230149901406738427651121855107737424232448.00000
0"
TagsNo tags attached.
Attached Files
config.log (218,005 bytes)
config64.log (249,396 bytes)

Activities

zesstra

2013-07-14 22:21

administrator   ~0002189

On 64 bit we use native doubles in the svalues. On 32 bit we fall back to our portable self-built floating format consisting of a 32 bit mantissa and 16 bit exponent. So the values of _FLOAT_MAX__ should be different on the two different architectures, since our 48 bit format looses precision.

However the json_serialize seems to truncate the string. So far I have no idea why (but had not much time so far to think about it).

Leonidas

2013-08-07 22:07

reporter   ~0002192

Problem persists with the new Cygwin64 (__INT_MAX__ / check of process confirm that the built ldmud.exe is 64 bit). Added the config64.log.

zesstra

2013-08-18 17:36

administrator   ~0002197

I now checked on my system with an explicitly set FLOAT_FORMAT_0, so it used the old float format with less precision although the system has a 64 bit wide long.

# xeval printf("%f", __FLOAT_MAX__)
179768999986252378853312007215479916353455467233213482490355090779201078386384833
219757013492100609085105372642211231151679503805856674832046277643434450552142122
262683019260926731591461211750693047408476003660744158081826761446893908409133392
686002330533205457001853426662731186060032405785913319192763826176

So. The result differs from the 64 Cygwin which is expected. The first part of the result is the same as on 32 bit Cygwin, which is like it should be.

However at some point on 32 bit cygwin sprintf() decides to actually round the number and replace the rest with 0 (53455500000... vs. 53455467233...).
It is not a simple trucation, but an actual rounding, which surprises me and looks like it is deliberate.

I checked in sprintf.c. For the printing of numbers we mostly fall back to the system sprintf(). So my first guess is: the system sprintf() on cygwin/32 has something to do with this. This would explain, why the problems is apparant in pkg-json.c and sprintf.c although those two have nothing in common and pkg-json.c does not use our own sprintf() - but probably the system sprintf().

zesstra

2013-08-18 18:10

administrator   ~0002198

Do you think it is possible for you to get the result of
printf("%.*f", 0, DBL_MAX);
in Cygwin/32?

zesstra

2013-08-18 18:28

administrator   ~0002199

There are some bugreports in cygwin dealing with incorrect printing of floats:
http://bugs.ecos.sourceware.org/show_bug.cgi?id=20804
http://bugs.ecos.sourceware.org/show_bug.cgi?id=1001628
especially printing to many 0. Maybe our problem is related to them.

Leonidas

2013-08-18 21:36

reporter   ~0002200

Seems you are right:

"179769313486231570814527423731704356798070600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

for both CygWin32/64.

zesstra

2013-08-18 22:19

administrator   ~0002202

Yeah, great... Somebody elses problem. ;-)

But now the question is why your tests in LDMud for Cygwin/64 seemed to work... :-(

Do you want to file a report to Cygwin or do we just wait if they fix the right thing?

Leonidas

2013-08-18 22:34

reporter   ~0002204

Err. The tests in 64 Cygwin don't work: the original note did say "32 Cygwin" versus "64 (Morgengrauen)". The problem is the same on 64 Cygwin, which only has been available for some weeks now.

"Somebody elses problem" sounds good enough for me, as nobody complained up to now. If somebody really wants to use Cygwin as actual live MUD base, we can file a report (or if I'll do if I'll ever find where to put the note).

zesstra

2013-08-18 22:43

administrator   ~0002206

Last edited: 2013-08-18 22:43

Leonidas suggested to close.
So I am doing that (for now). Let see when Cygwin works correctly. ;-)

Issue History

Date Modified Username Field Change
2013-07-12 15:23 Leonidas New Issue
2013-07-12 18:55 Leonidas File Added: config.log
2013-07-14 22:21 zesstra Note Added: 0002189
2013-08-07 22:06 Leonidas File Added: config64.log
2013-08-07 22:07 Leonidas Note Added: 0002192
2013-08-18 17:36 zesstra Note Added: 0002197
2013-08-18 18:10 zesstra Note Added: 0002198
2013-08-18 18:28 zesstra Note Added: 0002199
2013-08-18 21:36 Leonidas Note Added: 0002200
2013-08-18 22:19 zesstra Note Added: 0002202
2013-08-18 22:34 Leonidas Note Added: 0002204
2013-08-18 22:43 zesstra Note Added: 0002206
2013-08-18 22:43 zesstra Status new => closed
2013-08-18 22:43 zesstra Assigned To => zesstra
2013-08-18 22:43 zesstra Resolution open => no change required
2013-08-18 22:43 zesstra Note Edited: 0002206