Setting last N bits in an array
Posted
by Martin
on Stack Overflow
See other posts from Stack Overflow
or by Martin
Published on 2010-04-21T23:18:11Z
Indexed on
2010/04/21
23:23 UTC
Read the original article
Hit count: 206
I'm sure this is fairly simple, however I have a major mental block on it, so I need a little help here!
I have an array of 5 integers, the array is already filled with some data. I want to set the last N bits of the array to be random noise.
[int][int][int][int][int]
set last 40 bits
[unchanged][unchanged][unchanged][24 bits of old data followed 8 bits of randomness][all random]
This is largely language agnostic, but I'm working in C# so bonus points for answers in C#
© Stack Overflow or respective owner