- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Compute the bit-wise NOT of an array with signed integer type in Numpy

To compute the bit-wise NOT of an array with signed integer type, use the **numpy.bitwise_not()** method in Python Numpy. Computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator ˜.

The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. Note that if an uninitialized out array is created via the default out=None, locations within it where the condition is False will remain uninitialized.

NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.

## Steps

At first, import the required library −

import numpy as np

Create a 2d array. The datatype is set using the "dtype" parameter. We have set the datatype to signed integer type. When using signed integer types the result is the two's complement of the result for the unsigned type −

arr = np.array([[92, 81, 98, 45], [22, 67, 54, 69 ], [69, 80, 80, 99]], dtype=np.int8)

Displaying our array −

print("Array...\n",arr)

Get the datatype −

print("\nArray datatype...\n",arr.dtype)

Get the dimensions of the Array −

print("\nArray Dimensions...\n",arr.ndim)

Get the shape of the Array −

print("\nOur Array Shape...\n",arr.shape)

Get the number of elements of the Array −

print("\nElements in the Array...\n",arr.size)

To compute the bit-wise NOT of an array-wise, use the numpy.bitwise_not() method in Python Numpy −

print("\nResult (bit-wise NOT)...\n",np.bitwise_not(arr))

## Example

import numpy as np # Create a 2d array # The datatype is set using the "dtype" parameter # We have set the datatype to signed integer type # When using signed integer types the result is the two's complement of the result for the unsigned type arr = np.array([[92, 81, 98, 45], [22, 67, 54, 69 ], [69, 80, 80, 99]], dtype=np.int8) # Displaying our array print("Array...\n",arr) # Get the datatype print("\nArray datatype...\n",arr.dtype) # Get the dimensions of the Array print("\nArray Dimensions...\n",arr.ndim) # Get the shape of the Array print("\nOur Array Shape...\n",arr.shape) # Get the number of elements of the Array print("\nElements in the Array...\n",arr.size) # To compute the bit-wise NOT of an array-wise, use the numpy.bitwise_not() method in Python Numpy print("\nResult (bit-wise NOT)...\n",np.bitwise_not(arr))

## Output

Array... [[92 81 98 45] [22 67 54 69] [69 80 80 99]] Array datatype... int8 Array Dimensions... 2 Our Array Shape... (3, 4) Elements in the Array... 12 Result (bit-wise NOT)... [[ -93 -82 -99 -46] [ -23 -68 -55 -70] [ -70 -81 -81 -100]]

- Related Questions & Answers
- Compute the bit-wise NOT of an array element-wise in Numpy
- Compute the bit-wise NOT of a boolean array in Numpy
- Compute the bit-wise NOT of a One-Dimensional array element-wise in Numpy
- Compute the bit-wise NOT of a Two-Dimensional array element-wise in Numpy
- Compute the truth value of NOT an array element-wise in Numpy
- Compute the bit-wise XOR of two Numpy arrays element-wise
- Compute the bit-wise OR of two Numpy arrays element-wise
- Compute the bit-wise AND of two arrays element-wise in Numpy
- Compute the bit-wise OR of two boolean arrays element-wise in Numpy
- Compute the bit-wise AND of two boolean arrays element-wise in Numpy
- Compute the bit-wise XOR of two boolean arrays element-wise in Numpy
- Shift the bits of an integer to the right and set the count of shifts as an array with signed integer type in Numpy
- Compute the bit-wise XOR of a 1D and a 2D array element-wise in Numpy
- Compute the bit-wise AND of a 1D and a 2D array element-wise in Numpy
- Compute the bit-wise OR of a 1D and a 2D array element-wise in Numpy