Open In App

Python | Numpy np.min_scalar_type() method

With the help of np.min_scalar_type() method, we can get the minimum scalar type of a value that is passed as a parameter in np.min_scalar_type() method.

Syntax : np.min_scalar_type(value)
Return : Return the minimum scalar type of a value.



Example #1 :
In this example we can see that by using np.min_scalar_type() method, we are able to get the minimum scalar type of a value by using this method.




# import numpy
import numpy as np
  
# using np.min_scalar_type() method
gfg = np.min_scalar_type(-50)
  
print(gfg)

Output :

int8



Example #2 :




# import numpy
import numpy as np
  
# using np.min_scalar_type() method
gfg = np.min_scalar_type(55.56)
  
print(gfg)

Output :

float16

Article Tags :