Overview
| Artifact ID: | 16298620ca186b7cd6e1c8397c9d56354307ff10 |
|---|---|
| Ticket: | 2015452fffffffffffffffffffffffffffffffff
Negative integer division is wrong if there is a remainder |
| User & Date: | msofer on 2008-07-11 05:44:29 |
Changes
- closedate changed to: "2008-07-10T22:44:29"
- closer changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Originator: NO The problem is with the expectation! This is the behaviour by design. From the expr man page: "Multiply, divide, remainder. None of these operators may be applied to string operands, and remainder may be applied only to integers. The remainder will always have the same sign as the divisor and an absolute value smaller than the divisor." The observed behaviour is implied by this and general identity for integers a = (a/b)*b + (a%b) Note that the C standard makes no such promises about the sign of the remainder, different implementations may give different results. Note also that there is no "rounding", neither up nor down: this is just the way that integer division is defined.
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Invalid"
- status changed to: "Pending"
- username: "msofer"