Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

To do floor division and get an integer result (discarding any fractional result)

>>> 17 / 3  # classic division returns a float
5.666666666666667
>>>
>>> 17 // 3  # floor division discards the fractional part
5
>>> 17 % 3  # the % operator returns the remainder of the division
2
>>> 5 * 3 + 2  # floored quotient * divisor + remainder
17
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #To #floor #division #integer #result #fractional
ADD COMMENT
Topic
Name
2+7 =