mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
27 lines
604 B
C#
27 lines
604 B
C#
using System;
|
|
|
|
namespace S7.Net.Types
|
|
{
|
|
public static class Boolean
|
|
{
|
|
public static bool GetValue(byte value, int bit)
|
|
{
|
|
if ((value & (int)Math.Pow(2, bit)) != 0)
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
|
|
public static byte SetBit(byte value, int bit)
|
|
{
|
|
return (byte)(value | (byte)Math.Pow(2, bit));
|
|
}
|
|
|
|
public static byte ClearBit(byte value, int bit)
|
|
{
|
|
return (byte)(value & (byte)(~(byte)Math.Pow(2, bit)));
|
|
}
|
|
|
|
}
|
|
}
|