Python-divmod digital processing function

Source: Internet
Author: User
Python-divmod digital processing function python daily function-pmod digital processing function

Pmod (a, B) function

Chinese description:

The pmod (a, B) method returns a // B (division is an integer) and the remainder of a on B.

The returned result type is tuple.

Parameters:

A and B can be numbers (including plural numbers)

Version:

Complex numbers cannot be processed before python2.3.


English description:

Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using long pision. with mixed operand types, the rules for binary arithmetic operators apply. for plain and long integers, the result is the same as (a // B, a % B ). for floating point numbers the result is (q, a % B), where q is usually math. floor (a/B) but may be 1 less than that. in any case q * B + a % B is very close to a, if a % B is non-zero it has the same sign as B, and 0 <= abs (a % B) <abs (B ).


Changed in version 2.3: Using pmod () with complex numbers is deprecated.

Python code example:

>>> pmod(9,2)(4, 1)>>> pmod(11,3)(3, 2)>>> pmod(1+2j,1+0.5j)((1+0j), 1.5j)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.