Example of python3 int integer method function, python3 integer

Source: Internet
Author: User

Example of python3 int integer method function, python3 integer

_ Abs _ (return absolute value)

N =-5 print (n. _ abs _ () # output: 5

_ Add _ (addition, Operator: +)

N = 3 print (n. _ add _ (5) # output: 8

_ And _ (bitwise and OPERATION, Operator :&)

N = 5 print (n. _ and _ (7) # output: 5 #00000110 # equals to 00000111 #

_ Bool __

# Placeholder

_ Ceil _ (returns itself)

N = 1234 print (n. _ ceil _ () # output: 1234

_ Divmod _ (returns divisor and remainder)

N = 13 print (n. _ divmod _ (5) # output :( 2, 3)

_ Eq _ (determines whether two numbers are equal, Operator: =)

N = 5 print (n. _ eq _ (3) # output: False

_ Float _ (converted to floating point type)

N = 5 print (n. _ float _ () # output: 5.0

_ Floordiv _ (returns the integer part of the operator by Division. OPERATOR ://)

N = 9 print (n. _ floordiv _ (4) # output: 2

_ Floor __

# Placeholder

_ Format __

# Placeholder

_ Getattribute __

# Placeholder

_ Getnewargs __

# Placeholder

_ Ge _ (determine whether to >=)

N = 5 print (n. _ ge _ (3) # output: True

_ Gt _ (determine whether or not>)

N = 5 print (n. _ gt _ (3) # output: True

_ Hash __

# Placeholder

_ Index __

# Placeholder

_ Invert _ (bitwise inversion of binary values, Operator :~)

N = 11 print (n. _ invert _ () # output:-12 # ps: Negative binary number representation method: positive number, bitwise return, plus 1

_ Le _ (judge whether or not <=)

N = 5 print (n. _ le _ (3) # output: False

_ Lshift _ (Binary left shift operation, Operator: <)

N = 12 print (n. _ lshift _ (2) # output: 48 # ps: shifts the binary value 1 to 2 in decimal format, and shifts the right to 2 in decimal format.

_ Lt _ (determine whether or not <)

N = 5 print (n. _ lt _ (3) # output: False

_ Mod _ (Modulo-return the remainder of division, Operator: %)

N = 14 print (n. _ mod _ (3) # output: 2

_ Mul _ (multiplication, Operator :*)

N = 3 print (n. _ mul _ (6) # output: 18

_ Neg _ (reverse, positive value changes to negative number, negative value changes to positive number, operator :-)

N = 5 print (n. _ neg _ () # output:-5

_ New __

# Placeholder

_ Ne _ (determines whether the two values are not equal, Operator :! =)

N = 5 print (n. _ ne _ (3) # output: True

_ Or _ (bitwise or operation, Operator: |)

N = 3 print (n. _ or _ (5) # output: 7 #00000011 # or #00000110 #00000111 #

_ Pos __

# "" + Self "" (I don't know what it means)

_ Pow _ (returns the y Power of xy [x)

N = 2 print (n. _ pow _ (3) # output: 8

_ Radd _ (addition, Operator: +)

N = 5 print (n. _ radd _ (3) # output: 8

_ Rand __

#""" Return value&self. """

_ Rdivmod __

#""" Return divmod(value, self). """

_ Repr _ (returns itself)

#""" Return repr(self). """

_ Rfloordiv _ (returns the integer part of the operator by Division. OPERATOR ://)

#""" Return value//self. """

_ Rlshift _ (Binary left shift operation, Operator: <)

#""" Return value<<self. """

_ Rmod _ (Modulo-return the remainder of division, Operator: %)

#""" Return value%self. """

_ Rmul _ (multiplication, Operator :*)

#""" Return value*self. """

_ Ror __

#""" Return value|self. """

_ Round __

# Placeholder

_ Rpow _ (returns the x power of yx [y)

N = 3 print (n. _ rpow _ (2) # output: 8

_ Rrshift __

#""" Return value>>self. """

_ Rshift __

#""" Return self>>value. """

_ Rsub __

#""" Return value-self. """

_ Rtruediv __

#""" Return value/self. """

_ Rxor __

#""" Return value^self. """

_ Sizeof __

#""" Returns size in memory, in bytes """

_ Str __

#""" Return str(self). """

Sub (subtraction)

#""" Return self-value. """

_ Truediv _ (Division)

#""" Return self/value. """

_ Trunc __

# Placeholder

_ Xor _ (bitwise xor, Operator: ^)

#""" Return self^value. """
Bit_length (returns the minimum binary length)
>>> bin(37)'0b100101'>>> (37).bit_length()6

Conjugate

# Placeholder

From_bytes

# Placeholder

To_bytes

# Placeholder

 

 

 

 

 

 






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.