Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#3829 format conversion fails if arg is multiple-precision integer

obsolete: 8.5b2
closed-duplicate
Don Porter
5
2007-10-29
2007-10-27
kjnash
No

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
%

Discussion

    • assigned_to: dkf --> kennykb
     
  • Don Porter
    Don Porter
    2007-10-29

    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.

     
  • Don Porter
    Don Porter
    2007-10-29

    • assigned_to: kennykb --> dgp
    • status: open --> closed-duplicate