How to simulate C style integer division?
Peter Heitzer
peter.heitzer at rz.uni-regensburg.de
Thu Jan 21 03:44:38 EST 2016
More information about the Python-list mailing list
Thu Jan 21 03:44:38 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 ]
Shiyao Ma <i at introo.me> wrote: >Hi, >I wanna simulate C style integer division in Python3. >So far what I've got is: ># a, b = 3, 4 >import math >result = float(a) / b >if result > 0: > result = math.floor(result) >else: > result = math.ceil(result) >I found it's too laborious. Any quick way? In Python3 you have to use the floor division operator '//' For example: result=a//b
- 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