Skip to content
Tcl Source Code View Ticket
Login

View Ticket

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

Closed / Wont Fix1497990fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 20 years ago
Descriptionplain2006-05-31 07:28:22
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
like
      if (*p == ',') {
*p = '.';
      }
...

Greetings
Goeran
dkfplain2006-05-31 15:01:28
Logged In: YES 
user_id=79902

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.
ghankeplain2006-05-31 18:26:24
Logged In: YES 
user_id=1511137

strtod is also affected, so "expr 1.0" fails... This can be
fixed by adding strtod.$(OBJEXT) to COMPAT_OBJS
dgpplain2006-05-31 23:34:49
Logged In: YES 
user_id=80530


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.
sf-robotplain2006-06-15 09:23:53
Logged In: YES 
user_id=1312539

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).
sf-robot Closed ticket [1497990fff]. [History diff]2006-06-15 09:23:54
Log in (anonymous is fine) to add a comment.