- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 the scalar type of highest precision of the same kind as the input in Python
To return the scalar type of highest precision of the same kind as the input, use the maximum_sctype() method in Python Numpy. The parameter is the input data type. This can be a dtype object or an object that is convertible to a dtype.
Steps
At first, import the required library −
import numpy as np
Using the maximum_sctype() method in Numpy. Get the scalar type of highest precision −
print("Result...",np.maximum_sctype(int)) print("Result...",np.maximum_sctype(np.uint8)) print("Result...",np.maximum_sctype(complex)) print("Result...",np.maximum_sctype(str)) print("Result...",np.maximum_sctype('f4')) print("Result...",np.maximum_sctype('i2')) print("Result...",np.maximum_sctype('i4')) print("Result...",np.maximum_sctype('i8'))
Example
import numpy as np # To return the scalar type of highest precision of the same kind as the input, use the maximum_sctype() method in Python Numpy # The parameter is the input data type. This can be a dtype object or an object that is convertible to a dtype. print("Using the maximum_sctype() method in Numpy\n") # Get the scalar type of highest precision print("Result...",np.maximum_sctype(int)) print("Result...",np.maximum_sctype(np.uint8)) print("Result...",np.maximum_sctype(complex)) print("Result...",np.maximum_sctype(str)) print("Result...",np.maximum_sctype('f4')) print("Result...",np.maximum_sctype('i2')) print("Result...",np.maximum_sctype('i4')) print("Result...",np.maximum_sctype('i8'))
Output
Using the maximum_sctype() method in Numpy Result... <class 'numpy.int64'> Result... <class 'numpy.uint64'> Result... <class 'numpy.complex256'> Result... <class 'numpy.str_'> Result... <class 'numpy.float128'> Result... <class 'numpy.int64'> Result... <class 'numpy.int64'> Result... <class 'numpy.int64'>
- Related Articles
- Return a scalar type which is common to the input arrays in Python
- Return the scalar dtype or NumPy equivalent of Python type of an object
- Return the data type with the smallest size and scalar kind to which both the given types be safely cast in Python
- Return the string representation of a scalar dtype in Python
- Return the square of the complex-value input in Python
- Find the minimal data type of a scalar value in Python
- 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 the cumulative product treating NaNs as one but change the type of result in Python
- Return the base 2 logarithm of the input array in Python
- Return the element-wise square of the array input in Python
- Return the cumulative sum of array elements treating NaNs as zero but change the type of result in Python
- Return a new array with the same shape and type as given array in Numpy
- Return the floor of the input in Numpy
- What kind of mirror is required for obtaining a virtual image of the same size as the object?

Advertisements