Visit ComfyUI Online for ready-to-use ComfyUI environment
Perform bitwise shift operations on integer values, shifting bits left or right by specified positions.
The LogicUtil_LogicGateBitwiseShift
node is designed to perform bitwise shift operations on integer values. This node allows you to shift the bits of an integer (input1
) by a specified number of positions (input2
). A positive input2
value shifts the bits to the left, effectively multiplying the number by a power of two, while a negative input2
value shifts the bits to the right, effectively dividing the number by a power of two. This operation is particularly useful in scenarios where you need to perform efficient mathematical operations or manipulate binary data at a low level. The node ensures that the shift amount is within a valid range to prevent errors.
input1
is the integer value whose bits you want to shift. This parameter serves as the base number for the bitwise shift operation. The default value is 0, and it must be an integer. The value of input1
determines the initial binary representation that will be shifted.
input2
specifies the number of bit positions to shift input1
. A positive value shifts the bits to the left, while a negative value shifts the bits to the right. The default value is 0, and it must be an integer. The valid range for input2
is between -32 and 32, inclusive. This range ensures that the shift operation remains within the bounds of typical integer sizes.
The output is a single integer value resulting from the bitwise shift operation. This value represents the new integer obtained after shifting the bits of input1
by the number of positions specified in input2
. The output is crucial for applications requiring precise control over binary data manipulation or efficient mathematical computations.
input2
is within the range of -32 to 32 to avoid errors and ensure valid shift operations.input2
to perform left shifts (multiplication by powers of two) and negative values for right shifts (division by powers of two).ValueError: input2 must be between -32 and 32
input2
is outside the valid range of -32 to 32. - Solution: Ensure that the value of input2
is within the specified range. Adjust the value accordingly to fall between -32 and 32.TypeError: input1 and input2 must be integers
input1
or input2
is not an integer.input1
and input2
are provided as integer values. Convert any non-integer inputs to integers before using the node.© Copyright 2024 RunComfy. All Rights Reserved.