Divmod numeric processing function of Python function

Source: Internet
Author: User
Python daily one function-pmod numeric processing function

Pmod (A, B) function

English Description:

The Pmod (A, B) method returns a a//b (division rounding) and a to B remainder

Returns a result type of tuple

Parameters:

A, B can be a number (including plural)

Version:

It is not allowed to deal with complex numbers before the python2.3 version, so let's pay attention.

English Description:

Take the non complex numbers as arguments and return a pair of numbers consisting of their quotient and remainder when u Sing 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 was (q, a% b), where q is usually Math.floor (A/b) but could be 1 less than that. In any case Q * b + a% B are very close to a, if a% B is non-zero it had 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)
Related Article

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.