Posted to tcl by miguel at Tue Apr 29 19:52:08 GMT 2008view raw

  1. long lRemainder, lQuotient = l1 / l2;
  2.  
  3. /*
  4. * Force Tcl's integer division rules.
  5. * TODO: examine for logic simplification
  6. */
  7.  
  8. if ((lQuotient < 0 || (lQuotient == 0 &&
  9. ((l1 < 0 && l2 > 0) || (l1 > 0 && l2 < 0)))) &&
  10. (lQuotient * l2 != l1)) {
  11. lQuotient -= 1;
  12. }
  13. lRemainder = l1 - l2*lQuotient;