Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 9e94d53f56954d2da201d272ff4bc4dea921d3a9
Ticket: 218430ffffffffffffffffffffffffffffffffff
error in expr
User & Date: nobody on 2000-10-26 00:57:31
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 6011 Bug
    Version: 8.3.1
    SubmitDate: '2000-07-14'
    LastModified: '2000-07-17'
    Severity: SER
    Status: Closed
    Submitter: techsupp
    ChangedBy: ericm
    OS: All
    OSVersion: AIX Mac WIn98 SuSE Linux 6.4
    FixedDate: '2000-10-25'
    ClosedDate: '2000-07-17'
    
    
    Name:
    Alexander Schoepe
    
    CustomShell:
    no
    
    ReproducibleScript:
    expr int(19.49 * 100) % 10
    
    DesiredBehavior:
    result should be 9 but expr returns with 8
    
    
    
    As has been discussed on comp.lang.tcl, this is really a "feature" of how floating-point numbers are represented on a particular platform.  As Don Porter said:
    
    The Jedi seeks not exact results from floating point operations.
    
    % expr int(19.49 * 100) % 10
    8
    % expr int(19.49 * 100)
    1948
    % expr 19.49 * 100
    1949.0
    % set tcl_precision 17
    17
    % expr 19.49 * 100
    1948.9999999999998
    
    Every programmer eventually learns this lesson, but it's not a
    bug, nor a difficulty specific to Tcl.
    
    ---
       Eric Melski                            The Other Tcl Guy
       ericm at ajubasolutions.com            Ajuba Solutions
    
    -- 07/17/2000 ericm
    
    
    
  4. foundin changed to: "obsolete: 8.3.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "error in expr"
  11. type changed to: "Bug"