Platforms to show: All Mac Windows Linux Cross-Platform

Back to MemoryBlock class.

MemoryBlock.BitwiseOrMBS(Second as MemoryBlock, Dest as MemoryBlock = nil) as MemoryBlock
Type Topic Plugin Version macOS Windows Linux iOS Targets
method MemoryBlock MBS Util Plugin 22.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Function: Bitwise OR for a Memoryblock.

Dim m1 As New MemoryBlock(555)
Dim m2 As New MemoryBlock(555)
Dim r As New Random

For i As Integer = 0 To 555-1
m1.Byte(i) = r.InRange(0,255)
m2.Byte(i) = r.InRange(0,255)

Dim mAND As MemoryBlock = m1.BitwiseAndMBS(m2)
Dim mOR As MemoryBlock = m1.BitwiseOrMBS(m2)
Dim mXOR As MemoryBlock = m1.BitwiseXOrMBS(m2)

// check value
For i As Integer = 0 To 555-1
If BitwiseAnd(m1.Byte(i), m2.Byte(i)) <> mAND.Byte(i) Then
End If
If BitwiseOr(m1.Byte(i), m2.Byte(i)) <> mOR.Byte(i) Then
End If
If BitwiseXor(m1.Byte(i), m2.Byte(i)) <> mXOR.Byte(i) Then
End If


We walk over all values in current and second MemoryBlock and apply a bitwise OR to each byte and store that in the destination block.

If dest is nil, a new memoryblock is created. You can speed up processing with reusing the same memoryblock in iterations. If you pass a memoryblock, the plugin does not check the size of the memoryblock.

Returns nil on any error. For example if source is a memoryblock without a known size.

Blog Entries

The items on this page are in the following plugins: MBS Util Plugin.

💬 Ask a question or report a problem
The biggest plugin in space...

Start Chat