#3439 expr sqrt(2) returns 1,41421356237.0 after loading and using

obsolete: 8.4.13
Don Porter

TCL-Version: 8.4.13
OS: Windows 2000 SP4 / Windows XP SP2
Locale Settings: DE
- decimal symbol: ,
- digit grouping symbol .

After loading and using some packages the float
arithmetic is dead...

puts [expr sqrt(2)]
# => 1,41421356237.0

In consequence tkcon (and any text widget too) is
annoying me with errors...

This occurs rarely. On Win 2000 SP4 with tcom creating
wmi objects, and with tclodbc when using the ODBC
driver "Pervasive ODBC Client Interface"

ve SQL affected

fresh compiled TCL 8.4.12 (msys-mingw8) has this bug too.

The problem disappears using "." for decimal symbol
(Windows Control Center)

After some investigation I figure out this is not a TCL
bug but a bug in the sprintf function. This function
returns sometimes a ',' as decimal point

Perhaps take a hammer and blast them:
Insert in generic/tclUtil.c (Tcl_PrintDouble) something
if (*p == ',') {
*p = '.';



    • labels: 104236 --> 10. Objects
  • Logged In: YES

    The problem is that some drivers insist on setting the
    locale. Thanks a bunch, Oracle. (Same problem occurs with
    some HP printer drivers IIRC.)

    I believe this is fixed in 8.5 (by no longer using sprintf()
    to format numbers) and I believe the workaround for 8.4 is
    to reset the locale after loading the database drivers. I
    can't quite remember if that can be done at the Tcl level on
    Windows, or if it needs a little C code. :-(

    Leaving open for area maintainer (well, someone more
    knowledgable than me) to comment.

  • ghanke

    Logged In: YES

    strtod is also affected, so "expr 1.0" fails... This can be
    fixed by adding strtod.$(OBJEXT) to COMPAT_OBJS

  • Don Porter
    Don Porter

    Logged In: YES

    Tcl 8.5 is immune to this.

    Workaround for 8.4 is not
    to use broken extensions.

    If someone else has more
    sympathy, they're welcome
    to pick this up. I have no
    plans to work on it.

  • Don Porter
    Don Porter

    • status: open --> pending-wont-fix
  • Logged In: YES

    This Tracker item was closed automatically by the system. It was
    previously set to a Pending status, and the original submitter
    did not respond within 14 days (the time period specified by
    the administrator of this Tracker).

    • status: pending-wont-fix --> closed-wont-fix