This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients belopolsky, eric.smith, mark.dickinson
Date 2010-06-16.19:22:52
SpamBayes Score 0.09645795
Marked as misclassified No
Message-id <1276716174.88.0.0889060818762.issue9009@psf.upfronthosting.co.za>
In-reply-to
Content
Here's the section of the 'bigcomp' code that I was referring to above:

	/* Now b/d = exactly half-way between the two floating-point values */
	/* on either side of the input string.  Compute first digit of b/d. */

	if (!(dig = quorem(b,d))) {
		b = multadd(b, 10, 0);	/* very unlikely */
		dig = quorem(b,d);
		}

You can see it in the original source at http://www.netlib.org/fp/dtoa.c

This code is part of the algorithm for strtod.  Here b and d are Bigints, and b / d is a fraction that gives an approximation to the value of the input to strtod;  the aim is to produce the digits of b / d one-by-one to compare them with the strtod input, and (eventually) use the result of that comparison work out whether to round up or down.

If the condition of the 'if' block above is ever satisfied, b is multiplied by 10 (that's the multadd(b, 10, 0) call), so the fraction b / d is multiplied by 10 (with no corresponding correction for the strtod input string), and the wrong comparison is made!

There are many other similar pieces of code in _Py_dg_strtod that can never get called (I've run coverage programs over the code to help verify this);  trying to establish the correctness of the current code isn't easy.
History
Date User Action Args
2010-06-16 19:22:54mark.dickinsonsetrecipients: + mark.dickinson, belopolsky, eric.smith
2010-06-16 19:22:54mark.dickinsonsetmessageid: <1276716174.88.0.0889060818762.issue9009@psf.upfronthosting.co.za>
2010-06-16 19:22:53mark.dickinsonlinkissue9009 messages
2010-06-16 19:22:52mark.dickinsoncreate