Skip to content
Tcl Source Code View Ticket
Login

View Ticket

format conversion fails if arg is multiple-precision integer

Closed / Duplicate1821241fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-10-27 15:16:38
The result of an integer calculation using expr may or may not be a multiple-precision integer.

The format command's integer-to-string conversion specifiers %d %i %o %u %x and %X do not give valid results for multiple-precision integers.

Examples:

% set a [expr 0x530a8681a2ece111e52140ad89c6cc965c98ce10]
474080958589669057752601175750710414374396808720
% format %d $a
1553518096
% format %i $a
1553518096
% format %o $a
13446147020
% format %u $a
1553518096
% format %x $a
5c98ce10
% format %X $a
5C98CE10
%
dkf Ticket [1821241fff]: 1 change [History diff]2007-10-28 05:13:13
dgpplain2007-10-30 01:58:06
Logged In: YES 
user_id=80530
Originator: NO


You want the %lld format specifier.

The real bug here is that the docs
for [format] haven't caught up to
the implementation.  See 1446971.
Log in (anonymous is fine) to add a comment.