Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2017-04-05
08:14 • New ticket [4b12ccb336] format/scan %llu doesn't work. artifact: 1a617148c9 user: jan.nijtmans
2006-08-14
09:20 • Closed ticket [1527169fff]: scan incompatibility plus 6 other changes artifact: 55d8001b5f user: sf-robot
2006-07-30
23:51 • Pending ticket [1527169fff]. artifact: 0c5cb3a141 user: kennykb
23:51 • Ticket [1527169fff]: 4 changes artifact: 7ae5ac01d9 user: kennykb
2006-07-23
12:00 • Ticket [1527169fff]: 4 changes artifact: 0bebf6b750 user: dgp
04:38 • New ticket [1527169fff]. artifact: d5b6c062d7 user: dgp

[scan] incompatibility

Closed / Wont Fix1527169fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-07-23 04:38:59
On 64-bit system:

% info patch
8.4.14
% scan 0xfffff550 %x
-2736


% info patch
8.5a5
% scan 0xfffff550 %x
4294964560

TIP 237 doesn't appear
to call for this change.
A bug?
dgpplain2006-07-23 12:00:10
Logged In: YES 
user_id=80530


I know the revised docs
declare the new behavior
is correct, but don't trust
them; they were written by
the same fellow who wrote
the new code. :)
kennykbplain2006-07-30 23:51:38
Logged In: YES 
user_id=99768

Alas, Tcl has had a great many inconsistencies over time
with the way that integers larger than the precision of the
machine are handled, and the way that differences among
machines are handled.

Moving forward, we've taken the approach in 8.5 that Tcl's
integers are of arbitrary precision, and provided %llx,
%llo, %llu and %lld format groups that work the same on all
platforms.  We've also adopted the idea that %x, %o, %u and
%d are the width of a native 'long int' or 'long unsigned
int' - whatever that is on the platform - and that %lx, %lo,
%lu, and %ld are the width of a 'long long' (or __int64 in
the Microsoft compilers) or 'unsigned long long' (unsigned
__int64).

This does indeed introduce a handful of incompatibilities,
but it also fixes a number of insidious bugs, of which the
ones mentioned in TIP #237 are representative.

To constrain an integer to 'signed 32-bit', irrespective of
the platform's integer width or the input format, the
easiest thing at present is to combine the bit weights yourself:

    expr {($x & 0x7fffffff) - ($x & 0x80000000)}

This expression will give the value of the least significant
32 bits of any integer, interpreted as a signed
(twos-complement) 32-bit quantity.
kennykb Pending ticket [1527169fff]. [History diff]2006-07-30 23:51:39
sf-robotplain2006-08-14 09:20:36
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).
Log in (anonymous is fine) to add a comment.