
- 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
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
NumPy - bitwise_or
The bitwise OR operation on the corresponding bits of binary representations of integers in input arrays is computed by np.bitwise_or() function.
Example
import numpy as np a,b = 13,17 print 'Binary equivalents of 13 and 17:' print bin(a), bin(b) print 'Bitwise OR of 13 and 17:' print np.bitwise_or(13, 17)
Its output is as follows −
Binary equivalents of 13 and 17: 0b1101 0b10001 Bitwise OR of 13 and 17: 29
You can verify this output using the following table. Consider the following Bitwise OR truth table.
A | B | OR |
---|---|---|
1 | 1 | 1 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
1 | 1 | 0 | 1 | ||
AND | |||||
1 | 0 | 0 | 0 | 1 | |
result | 1 | 1 | 1 | 0 | 1 |
Decimal equivalent of 11101 is 29.
numpy_binary_operators.htm
Advertisements