
- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.invert()
This function computes the bitwise NOT result on integers in the input array. For signed integers, two's complement is returned.
Example
import numpy as np print 'Invert of 13 where dtype of ndarray is uint8:' print np.invert(np.array([13], dtype = np.uint8)) print '\n' # Comparing binary representation of 13 and 242, we find the inversion of bits print 'Binary representation of 13:' print np.binary_repr(13, width = 8) print '\n' print 'Binary representation of 242:' print np.binary_repr(242, width = 8)
Its output is as follows −
Invert of 13 where dtype of ndarray is uint8: [242] Binary representation of 13: 00001101 Binary representation of 242: 11110010
Note that np.binary_repr() function returns the binary representation of the decimal number in the given width.
numpy_binary_operators.htm
Advertisements