Menu

#1 Some Strings Incorrect Converted To Ints

open
nobody
None
5
2001-08-17
2001-08-17
Anonymous
No

General Tcl bug, described here ...

Tcl 8.3.1 and later.

Concise sample.

% expr 400000000
400000000
% expr 4000000000
-294967296
% expr 40000000000
integer value too large to represent

The text above gives concise example of problem. Here
is more from newsgroup posts.

Please notify me by e-mail when you begin working on
this problem. That way, if I begin work on it, it
won't be wasted effort (i.e. we should not have a
collision of effort).

Dave Ashley (dtashley@aol.com)
--------------------------

With Tcl 8.3.1 (but it may have been corrected by
now), Windows platform,
static build, i.e. my compilation under Microsoft
Visual C++.

I discovered that when I call the library function:

Tcl_GetIntFromObj()

there are some values of strings that are not
converted to integers
correctly.

Here are the examples:

The string "-400000000" (there are eight zeros there)
is converted
correctly.

The string "-4000000000" (there are nine zeros there)
is converted to
294967296, but TCL_OK is returned.

The string "-40000000000" (there are ten zeros there)
causes TCL_ERROR to be
returned.

There is a window of positive and negative numbers
where the number is
converted incorrectly to integer format, but TCL_OK is
returned. The
example with nine zeros is in this window.

Another more simple way to show the bug is:
% expr -400000000 * 1
-400000000
% expr -4000000000 * 1
294967296
% expr -40000000000 * 1
integer value too large to represent
% expr 400000000 * 1
400000000
% expr 4000000000 * 1
-294967296
% expr 40000000000 * 1
integer value too large to represent
%

The bug is in the function.
SetIntFromAny(interp, objPtr)

Discussion


Log in to post a comment.

Monday.com Logo