Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1cb6bb5f6e735afdf2c9dc4d04f56723c94405f0
Ticket: 866469ffffffffffffffffffffffffffffffffff
Integers aren't strings anymore
User & Date: lars_h on 2003-12-27 23:11:55
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Throughout most of Tcl8, there has been a bug (or 
    malfeature of the tcl_precision variable) that two float 
    values can have identical string representations but 
    still behave differently when operated on. I hope that 
    TIP 132 will soon correct this.
    
    Although floats have been slightly magical, one has 
    however always been able to rely on integers to not hide 
    any information from the string representation. Sadly, 
    that isn't true anymore. Behold:
    
    % set l [expr 65536]
    65536
    % set w [expr {wide($l)}]
    65536
    % string equal $l $w
    1
    % expr {$l * 65536}
    0
    % expr {$w * 65536}
    4294967296
    
    In short, the bug is that [expr] lets its result depend 
    on details of the internal representation that are not 
    recorded in the string representation.
    
    
    In a larger perspective, I think this is a symptom of a 
    failure to clearly decide what an integer should be in 
    Tcl, but sortinh that out requires a TIP. (IMHO the only 
    approach that has a chance of being consistent is to 
    allow arbitrarily long decimal strings as integers, as 
    now use efficient internal representations for integers 
    up to 32 or 64 bits, and rely on some callback similar 
    to [unknown] for all operations on larger numbers.)
    
    
  4. foundin changed to: "obsolete: 8.4.5"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "lars_h"
  9. subsystem changed to: "16. Commands A-H"
  10. title changed to: "Integers aren't strings anymore"
  11. type changed to: "RFE"