forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitManipulator.cs
More file actions
34 lines (29 loc) · 805 Bytes
/
BitManipulator.cs
File metadata and controls
34 lines (29 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System;
namespace HoloToolkit.Unity
{
/// <summary>
/// Helper class for bit manipulation.
/// </summary>
public class BitManipulator
{
Int32 mask;
Int32 shift;
public BitManipulator(Int32 mask, Int32 shift)
{
this.mask = mask;
this.shift = shift;
}
public Int32 GetBitsValue(Int32 input)
{
return (input & mask) >> shift;
}
public void SetBits(ref Int32 value, Int32 bitsValue)
{
Int32 iT = bitsValue << shift;
iT = iT & mask;
value = value | iT;
}
}
}