Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
numpy
python
signbit

# What is the numpy.signbit() function in NumPy? Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.   ## Overview

The numpy.signbit() function in NumPy is used to return a True value for each element of an input array where the signbit is set (less than 0).

Note: The Signbit  indicates the sign of a number. In this case, the numpy.signbit() function will return True for any element less than zero.

### Syntax

numpy.sgnbit(x, /, out=None, *, where=True)
Syntax for the numpy.signbit() function

### Parameter value

The numpy.signbit() function takes the following parameter values:

• x : The input array. This is a required parameter.
• out : The location where the result is stored. This is an optional parameter.
• where : The condition over which the input is broadcasted. At a given location where this condition is True, the resulting array will be set to the ufunc result. Otherwise, the resulting array will retain its original value. This is an optional parameter.
• **kwargs : The other keyword arguments. This is an optional parameter.

### Return value

The numpy.signbit() function returns an array of Boolean values.

### Example

Let's look at the example below:

import numpy as np

# creating an array
x = np.array([0.5, -0.5, 100, 1, -1, 0.05])

# implementing the numpy.signbit() function
myarray = np.signbit(x)

print(x)
print(myarray)
Implementing the numpy.signbit() function

### Explanation

• Line 1: We import the numpy module.
• Line 4: We create an array, x, using the array() method.
• Line 7: We implement the np.signbit() function on the array. The result is assigned to a variable, myarray.
• Line 9: We print the input array x.
• Line 10: We print the variable myarray.

RELATED TAGS

function
numpy
python
signbit

CONTRIBUTOR Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.   Keep Exploring

Learn in-demand tech skills in half the time 