Skip to content

ByteExtensions Class

Definition

Extension methods for Byte.

public static class ByteExtensions

View source

Methods

Name Description
CopyBitsFrom(Byte, Byte, Byte) Copies bits from one byte to another using a mask.
DidAdditionHalfCarry(Byte, Byte, Byte) Determines whether an addition produced a half carry, i.e. a carry from bit 3 to bit 4.
DidAdditionOverflow(Byte, Byte, Byte) Determines whether a signed addition overflowed by examining the sum and its operands.
DidSubtractionHalfBorrow(Byte, Byte, Byte) Determines whether a subtraction produced a half borrow, i.e. a borrow from bit 4 to bit 3.
DidSubtractionOverflow(Byte, Byte, Byte) Determines whether a signed subtraction overflowed by examining the difference and its operands.
GetBit(Byte, Int32) Gets the value of the bit at the specified index.
GetBits(Byte, Int32, Int32) Gets a range of bits from a byte, shifted down to the least significant position.
HighNibble(Byte) Gets the high nibble (bits 4-7) of a byte, shifted down to the least significant position.
LeftMostBit(Byte) Gets the left-most bit (bit 7) of a byte.
LowNibble(Byte) Gets the low nibble (bits 0-3) of a byte.
Parity(Byte) Gets the parity of a byte, i.e. whether the number of set bits is even.
ResetBit(Byte, Int32) Returns a new byte with the bit at the specified index cleared.
RightMostBit(Byte) Gets the right-most bit (bit 0) of a byte.
SetBit(Byte, Int32) Returns a new byte with the bit at the specified index set.
SetBits(Byte, Byte, Int32, Int32) Sets a range of bits in a byte to the specified value.
SetHighNibble(Byte, Byte) Returns a new byte with the high nibble (bits 4-7) set to the specified value.
SetLowNibble(Byte, Byte) Returns a new byte with the low nibble (bits 0-3) set to the specified value.
SignBit(Byte) Gets the sign bit (bit 7) of a byte.
ToBinaryString(Byte) Converts a byte to its binary string representation, e.g. "0b01011010".