- 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

# Return mantissa and exponent as a pair of a given array in Numpy

To return mantissa and exponent as a pair of a given array, use the **numpy.frexp()** method in Python Numpy. The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

The condition is 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 an array −

arr = np.array([6.8, 31.9, 100.8, 50, -10.5, np.nan, np.inf])

Display the array −

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

Get the type of the array −

print("\nOur Array type...\n", arr.dtype)

Get the dimensions of the Array −

print("\nOur Array Dimensions...\n", arr.ndim)

Get the number of elements in the Array −

print("\nNumber of elements...\n", arr.size)

To return mantissa and exponent as a pair of a given array, use the numpy.frexp() method in Python Numpy −

print("\nResult...\n",np.frexp(arr))

## Example

import numpy as np # Create an array arr = np.array([6.8, 31.9, 100.8, 50, -10.5, np.nan, np.inf]) # Display the array print("Array...\n", arr) # Get the type of the array print("\nOur Array type...\n", arr.dtype) # Get the dimensions of the Array print("\nOur Array Dimensions...\n", arr.ndim) # Get the number of elements in the Array print("\nNumber of elements...\n", arr.size) # To return mantissa and exponent as a pair of a given array, use the numpy.frexp() method in Python Numpy print("\nResult...\n",np.frexp(arr))

## Output

Array... [ 6.8 31.9 100.8 50. -10.5 nan inf] Our Array type... float64 Our Array Dimensions... 1 Number of elements... 7 Result... (array([ 0.85 , 0.996875, 0.7875 , 0.78125 , -0.65625 , nan, inf]), array([3, 5, 7, 6, 4, 0, 0], dtype=int32))

- Related Questions & Answers
- Return mantissa and exponent as a pair of a given value in Numpy
- Return mantissa and exponent as a pair of a given list in Numpy
- Return mantissa and exponent as a pair of a given tuple in Numpy
- Return mantissa and exponent as a pair for a specific array element in Numpy
- Return mantissa and exponent as a pair for a specific list element in Numpy
- Return mantissa and exponent as a pair for a specific tuple element in Numpy
- Return a new array with the same shape and type as a given array in Numpy
- Return a full array with the same shape and type as a given array in Numpy
- Return a new array with the same shape and type as given array in Numpy
- Return an array of ones with the same shape and type as a given array in Numpy
- Return an array of zeros with the same shape and type as a given array in Numpy
- Return a new array with the same shape and type as a given array and change the order in Numpy
- Return a new array of given shape and type, filled with array-like in Numpy
- Return an array of zeroes with the same shape as a given array but with a different type in Numpy
- Return the pickle of the masked array as a string in NumPy