Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-04-12
04:07 • Closed ticket [718878ffff]: string is integer inconsistency plus 7 other c... artifact: 3605345c9d user: dgp
2003-04-10
22:40 • Ticket [718878ffff]: 4 changes artifact: a4fc35a68b user: rmax
22:34 • Ticket [718878ffff]: 5 changes artifact: dfaf24d80d user: dgp
09:13 • New ticket [718878ffff]. artifact: 8d7042a3d0 user: rmax

[string is integer] inconsistency

Closed / Fixed718878ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2003-04-10 09:13:27
Given the following two commands:

 string is integer 12345678901
 string is integer [expr 12345678901]

On i386 they both return 0, but on x86_64
the second one returns 1. 

I think they should return 1 on all platforms
that support wide integers.
dgpplain2003-04-10 22:34:49
Logged In: YES 
user_id=80530


Note that this bug is present in 8.3.5;
it has nothing to do with wide integers.

For value with only a string rep,
[string is integer] asks "Can this
string be read as a C "int" ?"

For values that already have an integer
internal type, it asks "Does this value
fit in a C "long" ?"

For any platform where sizeof(long) != sizeof(int),
the answers will not be consistent.

Making them consistent is easy, but that
requires knowing which answer is the right
one.  The docs do not specify in enough detail.
rmaxplain2003-04-10 22:40:53
Logged In: YES 
user_id=124643

Does that mean it would need a TIP to get defined semantics
for [string is integer], and then fix the implementation?
dgpplain2003-04-12 04:07:53
Logged In: YES 
user_id=80530

committed fix to make [string is integer] 
consistently recognize 32-bit integers
(C int's) for both string and internal
representations, and across platforms.
Updated docs and tests.

If we want something to recognize either
64-bit integers consistently, or platform
C longs in a platform-specific manner, we
need a TIP to either change [string is integer],
or provide another command ([string is wide] ?).
Log in (anonymous is fine) to add a comment.