Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: c27113cc102e658f532571518aa5b1d76a501386
Ticket: 2015452fffffffffffffffffffffffffffffffff
Negative integer division is wrong if there is a remainder
User & Date: karll on 2008-07-10 22:27:41
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    If I divide a negative integer by an integer and there is a remainder, Tcl will round the result downward.  This has been replicated on Mac and FreeBSD.
    
    tclsh8.4
    % expr -501/500
    -2
    
    % expr -1000001/1000000
    -2
    
    Let's try a C program to see if I am crazy.
    
    $ cat foo.c
    
    main()
    {
        int i = -86401 / 86400;
        printf("%d\n", i);
    }
    
    $ cc foo.c
    $ ./a.out
    -1
    
    It works as expected.
    
    
    
  4. foundin changed to: "obsolete: 8.4.19"
  5. is_private changed to: "0"
  6. priority changed to: "9 Immediate"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "karll"
  10. subsystem changed to: "16. Commands A-H"
  11. title changed to:
    Negative integer division is wrong if there is a remainder
    
  12. type changed to: "Bug"