using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Noddybox.Emulation.EightBit
{
///
/// Provides helpers for shifting smaller values around without casts all over the shop.
///
public static class Binary
{
///
/// Shift 8-bits to the left.
///
/// The byte.
/// How many bits to shift.
/// The shifted value.
public static byte ShiftLeft(byte b, int shift)
{
return (byte)((b << shift) & 0xff);
}
///
/// Shift 8-bits to the right.
///
/// The byte.
/// How many bits to shift.
/// The shifted value.
public static byte ShiftRight(byte b, int shift)
{
return (byte)((b >> shift) & 0xff);
}
///
/// Shift 16-bits to the left.
///
/// The word.
/// How many bits to shift.
/// The shifted value.
public static ushort ShiftLeft(ushort w, int shift)
{
return (ushort)((w << shift) & 0xffff);
}
///
/// Shift 16-bits to the right.
///
/// The word.
/// How many bits to shift.
/// The shifted value.
public static ushort ShiftRight(ushort w, int shift)
{
return (ushort)((w >> shift) & 0xffff);
}
}
}