Ticket UUID: | 3120139 | |||
Title: | Tcl_PrintDouble not locale-safe | |||
Type: | Bug | Version: | obsolete: 8.6b1.1 | |
Submitter: | hobbs | Created on: | 2010-11-26 23:56:14 | |
Subsystem: | 10. Objects | Assigned To: | kennykb | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2010-12-01 23:46:50 | |
Resolution: | Fixed | Closed By: | kennykb | |
Closed on: | 2010-12-01 16:46:50 | |||
Description: |
If the locale is set up to not be LC_NUMERIC=C, Tcl_PrintDouble can give odd behavior. I am able to reproduce this by using a French regional locale (Control Panel -> Regional Locale and Settings), starting python with tkinter, where they have called locale.setlocale(locale.LC_ALL, '') but this could occur in other instances of Tcl embedded. When in this case, Tcl_PrintDouble can produce odd results: (arelle) 61 % expr 2-0.1 1,8999999999999999.0 (arelle) 62 % set tcl_precision 5 5 (arelle) 63 % expr 2-0.1 1,9.0 This is because the .0 tack-on is locale-ignorant. | |||
User Comments: |
nijtmans added on 2010-11-29 04:35:14:
Well, I object to the NaN-tests (util-14.1 and 14.2), without a proper discussion, related to bug 3105247. The fact that those tests were missing here, implies that the formatting of funky NaN values was an oversight, and not an intended behavior. (For the numerical parser, TIP #249, I believe it was intentional but that's tested somewhere else). And those tests have no relation to this bug #3120139 Apart from that, this patch looks good. The function's name is TclDoubleDigits, but in the test cases it is refered as Tcl_DoubleDigits; Was it originally meant to be public? kennykb added on 2010-11-28 00:50:46: File Added - 394576: double.patch kennykb added on 2010-11-28 00:49:55: The attached patch is a complete rewrite of TclDoubleDigits, motivated largely by performance considerations. It exploits a number of important special cases to avoid hideously expensive mp_div operations; for all numbers less than 10**26, it requires no mp_div calls, and for numbers in that range that are at least 10**-3, it requires no bignum arithmetic at all. It is well tested only on Linux-x86 -- and no attempt has been made to tweak the build system to add the two additional needed libtommath files to the MacOSX build. It should be at least vetted on Windows (and the Mac build repaired and tested) before committing. It's a big enough change that I'm a little nervous about backporting it, and I welcome advice. |
Attachments:
- double.patch [download] added by kennykb on 2010-11-28 00:50:46. [details]