How to simulate C style integer division?
Jussi Piitulainen
jussi.piitulainen at helsinki.fi
Sat Jan 23 10:07:22 EST 2016
More information about the Python-list mailing list
Sat Jan 23 10:07:22 EST 2016
- Previous message (by thread): How to simulate C style integer division?
- Next message (by thread): How to simulate C style integer division?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Grobu writes: >> def intdiv(a, b): >> return (a - (a % (-b if a < 0 else b))) / b >> >> > > Duh ... Got confused with modulos (again). > > def intdiv(a, b): > return (a - (a % (-abs(b) if a < 0 else abs(b)))) / b You should use // here to get an exact integer result.
- Previous message (by thread): How to simulate C style integer division?
- Next message (by thread): How to simulate C style integer division?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list