Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7cea7f851d8aa5b906de6adc868a3f98c3374677
Ticket: 2848176fffffffffffffffffffffffffffffffff
Invalid results from "expr", v8.4.*, v8.5.*, v8.6.*
User & Date: dgp on 2009-09-02 00:14:23
Changes

  1. icomment:
    
    This is not a bug.  It is an intentional feature change.
    
    Starting with release Tcl 8.4.0 in 2002 (!) the numeric
    literal value "0x80000000" is taken as the number 2147483648 .
    This is an incompatible change from Tcl 8.3 and earlier
    where the interpretation was platform dependent.  On 32-bit
    systems it was the number -2147483648 and on 64-bit
    systems it was the number 2147483648.  It was TIP 72
    that started this change, and since then TIP 237 extended
    the change so that integer literals are interpreted within
    a system of unlimited range and no overflows at all.
    If you want a negative number in hex notation, you must
    lead with the minus sign.
    
    Also, do not over look the "l" and "ll" modifers in your
    [format] spec's:
    
    % format %#x [expr ~0x80000000]
    0x7fffffff
    % format %#lx [expr ~0x80000000]
    0xffffffff7fffffff
    % format %#llx [expr ~0x80000000]
    -0x80000001
    
    
    Sounds like the crc*.tcl files you have are buggy.  Even
    when they might have been used with Tcl 8.3, they were
    still buggy, since they did not work on 64-bit systems.  Check
    that you are still using some that are out of date.  If not,
    report the bugs to the maintainer(s) of the package(s).
    
    The possibly legitimate gripe against Tcl is that
    Tcl does not provide any good tools in the built-in
    command set to easily, efficiently, and with complete
    cross-platform agreement operate on data known
    to be "32-bit integers"  or "64-bit integers".  Tcl leaves
    too many of the definitional details to the underlying
    C implementation.  Tcl scripts that really want to operate
    on 32-bit buffers find that they are forced to to a lot of
    masking against 0xFFFFFFFF to get the job done right.
    Whether the right answer to this problem is more 
    operators and options in Tcl's built-ins or a good
    extension or two, is a matter for someone motivated
    to pursue.
    
    
  2. login: "dgp"
  3. mimetype: "text/plain"
  4. username: "dgp"