Skip to content
Tcl Source Code History Of Ticket 218045
Login

History Of Ticket 218045

Artifacts Associated With Ticket 218045

  1. Ticket change [995e2537b1] (rid 110782) by nobody on 2000-10-26 00:52:32:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 1384 Bug
      Version: 8.0.3
      SubmitDate: '1999-03-02'
      LastModified: '1999-08-07'
      Severity: MED
      Status: Closed
      Submitter: pat
      ChangedBy: hobbs
      OS: HP-UX
      OSVersion: 10.20
      Machine: Other
      FixedDate: '2000-10-25'
      ClosedDate: '1999-08-07'
      
      
      Name:
      Bob Fletcher
      
      Extensions:
      expect
      
      CustomShell:
      None
      
      ReproducibleScript:
      #!/bin/sh
      # the next line restarts using wish  exec wish "$0" "$@"
      
      for {set i -10} {$i <= 10} {incr i} {
              set x $i
              puts "i $i [expr {$i%10}] $x [expr {fmod($x,10.)}]"
      }       
      exit
      
      ObservedBehavior:
      This is the cl8.03 output for this expr % test.
      i -10 0 -10 0.0
      i -9 1 -9 -9.0
      i -8 2 -8 -8.0
      i -7 3 -7 -7.0
      i -6 4 -6 -6.0
      i -5 5 -5 -5.0
      i -4 6 -4 -4.0
      i -3 7 -3 -3.0
      i -2 8 -2 -2.0
      i -1 9 -1 -1.0
      i 0 0 0 0.0
      i 1 1 1 1.0
      i 2 2 2 2.0
      i 3 3 3 3.0
      i 4 4 4 4.0
      i 5 5 5 5.0
      i 6 6 6 6.0
      i 7 7 7 7.0
      i 8 8 8 8.0
      i 9 9 9 9.0
      i 10 0 10 0.0
      
      This is the output from a similar f77 code.
      i -10 0 -10.0 .0
       i -9 -9 -9.0 -9.0
       i -8 -8 -8.0 -8.0
       i -7 -7 -7.0 -7.0
       i -6 -6 -6.0 -6.0
       i -5 -5 -5.0 -5.0
       i -4 -4 -4.0 -4.0
       i -3 -3 -3.0 -3.0
       i -2 -2 -2.0 -2.0
       i -1 -1 -1.0 -1.0
       i 0 0 .0 .0
       i 1 1 1.0 1.0
       i 2 2 2.0 2.0
       i 3 3 3.0 3.0
       i 4 4 4.0 4.0
       i 5 5 5.0 5.0
       i 6 6 6.0 6.0
       i 7 7 7.0 7.0
       i 8 8 8.0 8.0
       i 9 9 9.0 9.0
       i 10 0 10.0 .0
      
      The tcl expr command gives, for negative numbers, gives different answers than the  tcl floating point  fmod command, and different answers from f77/C.
      We would expect % to give the same answer as fmod, when the floating point is equivalent to an int. 
      
      DesiredBehavior:
      We would expect % to give the same answer as fmod, when the floating point is equivalent to an int. 
      
      
      
      Note the comments in tclExecute.c:
      
      case INST_MOD:
          /*
           * This code is tricky: C doesn't guarantee much about
           * the quotient or remainder, but Tcl does. The
           * remainder always has the same sign as the divisor and
           * a smaller absolute value.
           */
      
      K&R states specfically (p41, 2nd ed) that the sign of the
      result for % is machine-dependent for negative operands.
      Thus Tcl only formalizes this with a more strict definition. 
      -- 08/07/1999 hobbs
      
    4. foundin initialized to: "obsolete: 8.0.3"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: "% operator gives incorrect answer."
    11. type initialized to: "Bug"
  2. Ticket change [c6fd29bd7c] (rid 121862) by welch on 2000-10-26 08:13:43:

    1. closedate changed to: "2000-10-26T01:13:43"
    2. closer changed to: "welch"
    3. priority changed to: "2"
    4. resolution changed to: "Fixed"
    5. status changed to: "Closed"
  3. Ticket change [2d7ad4ea4e] (rid 119075) by dgp on 2001-04-16 22:57:44:

    1. closedate changed to: "2001-04-16T15:57:44"
    2. closer changed to: "dgp"
    3. subsystem changed to: "16. Commands A-H"