The division of the number of shapes in the C + + language is performed by dividing the floor (the number of decimal parts). such as int a=15/10; The result of a is 1.
The same is true in Java, so it is necessary to force type conversions when dividing data for two int to return a floating-point data, such as float a = (float) b/c, where B and c are int data.
Python is divided into 3 divisions: traditional Division, Precision division, and floor removal.
Traditional Division
If it is an integer except the law performs a floor divide, if it is a floating-point number, the law performs a precise division.
>>>1/2 0 >>>1.0/2.0 0.5
Exact division
Division always returns the real quotient, regardless of whether the operand is shaped or floating. This can be done by executing the From __FUTURE__ Import Division directive.
>>>from __future__ Import Division >>>1/20.5>>>1.0/2.00.5
Floor removal
Starting with Python2.2, an operator//is added to perform the floor division://Divide regardless of the numeric type of the operand, the fractional part is always removed, returning the nearest number in the sequence of numbers that is smaller than the true quotient.
>>>1//20>>>1.0//20>>>-1//2.0-1
Built-in function divmod ()
Divmod (A, B), return (A//B,A%B)
>>>divmod ( 0,1) >>>divmod (3.14159,1.5) (2.0,0.4159000000000002) > >>5+6j//3+2j2+0j>>>5+6j%3+2j-1+2j>>>divmod (5+6J,3+2J) ((2+0j), ( -1+2J))
Division in Python