Skip to content

Commit 140794c

Browse files
committed
Mask #width bits in value to write in setBits
1 parent 99a1b5c commit 140794c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Utilities/Util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ template <typename T>
5151
void setBits(T& bits, int index, int width, uint32_t value)
5252
{
5353
uint32_t mask = ~(~T(0)<<width) << index;
54-
bits = (bits & ~mask) | (value << index);
54+
bits = (bits & ~mask) | ((value << index) & mask);
5555
}
5656

5757
template <typename T>

0 commit comments

Comments
 (0)