Skip to content
Tcl Source Code History Of Ticket 1228275
Login

History Of Ticket 1228275

Artifacts Associated With Ticket 1228275

  1. Ticket change [ac7b556454] (rid 101299) by matzek on 2005-06-27 13:55:26:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Hi *,
      
      although I haven't found much documentation about this
      [expr] behavior, Welch et al. are writing: "The result
      of an arithmetic operation is [...] a wide integer if
      at least one of the operands is a wide integer, and a
      normal integer otherwise." And the manual of [expr]
      says: "wide(arg): Converts arg to an integer value at
      least 64-bits wide (by sign-extension if arg is a
      32-bit number) if it is not one already."
      
      I now have two values, both fitting into a signed
      integer, which would need a wide integer when summed
      up. But I am somehow unable to get the right result:
      
      $ tcl-8.4.9/bin/tclsh8.4 
      % expr {(1<<31)+1}
      -2147483647
      % expr {(1<<31)+wide(1)}
      -2147483647
      % expr {wide(1<<31)+1}
      -2147483647
      % expr {wide((1<<31))+1}
      -2147483647
      % expr {wide((1<<31)+1)}
      -2147483647
      
      On a 64bit system and compiled with --enable-64bit, I
      get the right result, right from the start:
      
      $ tcl-8.4.9/bin/tclsh8.4          
      % expr {(1<<31)+1}
      2147483649
      
      -- Matthias Kraft
      
    4. foundin initialized to: "obsolete: 8.4.9"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "matzek"
    9. subsystem initialized to: "16. Commands A-H"
    10. title initialized to:
      [expr] cannot cope with wideInt results on 32bit UNIX
      
    11. type initialized to: "Bug"
  2. Ticket change [166b6dbf97] (rid 124714) by dkf on 2005-06-27 21:03:47:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      The problem is that it is the << operation that is doing the
      wrong thing with the signs, and not the operations around
      it. On a 32-bit system:
      
      % expr (wide(1)<<31)+1
      2147483649
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [49122ebd77] (rid 100005) by matzek on 2005-06-27 21:13:28:

    1. icomment:
      Logged In: YES 
      user_id=330806
      
      Oh, yes ... well that solves my problem, feel free to close
      then.
      
      
    2. login: "matzek"
    3. mimetype: "text/plain"
    4. username: "matzek"
  4. Ticket change [8a50da5e85] (rid 127373) by mdejong on 2005-06-30 04:14:14:

    1. icomment:
      Logged In: YES 
      user_id=90858
      
      I think this is what you meant to do. 1<<31 is a negative
      number.
      
      % expr {(1<<31)-1}
      2147483647
      
      % expr {wide(1<<31)-1}
      -2147483649
      
      
      
    2. login: "mdejong"
    3. mimetype: "text/plain"
    4. username: "mdejong"
  5. Ticket change [6d49dab446] (rid 128668) by mdejong on 2005-08-24 01:37:16:

    1. closedate changed to: "2005-08-23T18:37:16"
    2. closer changed to: "mdejong"
    3. resolution changed to: "Invalid"
    4. status changed to: "Closed"