Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: ac7b5564544794cc40ecc7c513cf900f21c68ebc
Ticket: 1228275fffffffffffffffffffffffffffffffff
[expr] cannot cope with wideInt results on 32bit UNIX
User & Date: matzek on 2005-06-27 13:55:26
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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 changed to: "obsolete: 8.4.9"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "matzek"
  9. subsystem changed to: "16. Commands A-H"
  10. title changed to:
    [expr] cannot cope with wideInt results on 32bit UNIX
    
  11. type changed to: "Bug"