public bool Equals(UInt48 other) { if ((int)this._mostSignificant == (int)other._mostSignificant) { return((int)this._leastSignificant == (int)other._leastSignificant); } return(false); }
private static UInt48 HostToNetworkOrder(UInt48 value) { UInt48 result; unsafe { UInt48* resultPtr = &result; byte* resultBytePtr = (byte*)resultPtr; UInt48* valuePtr = &value; byte* valueBytePtr = (byte*)valuePtr; resultBytePtr[0] = valueBytePtr[5]; resultBytePtr[1] = valueBytePtr[4]; resultBytePtr[2] = valueBytePtr[3]; resultBytePtr[3] = valueBytePtr[2]; resultBytePtr[4] = valueBytePtr[1]; resultBytePtr[5] = valueBytePtr[0]; } return result; }
/// <summary> /// Writes the given value to the buffer using the given endianity and increments the offset by the number of bytes written. /// </summary> /// <param name="buffer">The buffer to write the value to.</param> /// <param name="offset">The offset in the buffer to start writing.</param> /// <param name="value">The value to write.</param> /// <param name="endianity">The endianity to use when converting the value to bytes.</param> public static void Write(this byte[] buffer, ref int offset, UInt48 value, Endianity endianity) { buffer.Write(offset, value, endianity); offset += UInt48.SizeOf; }
/// <summary> /// Writes the given value to the buffer using the given endianity. /// </summary> /// <param name="buffer">The buffer to write the value to.</param> /// <param name="offset">The offset in the buffer to start writing.</param> /// <param name="value">The value to write.</param> /// <param name="endianity">The endianity to use when converting the value to bytes.</param> public static void Write(this byte[] buffer, int offset, UInt48 value, Endianity endianity) { if (IsWrongEndianity(endianity)) value = HostToNetworkOrder(value); Write(buffer, offset, value); }
private static void Write(byte[] buffer, int offset, UInt48 value) { unsafe { fixed (byte* ptr = &buffer[offset]) { *((UInt48*)ptr) = value; } } }
/// <summary> /// Returns true iff the two values represent the same value. /// </summary> /// <param name="other">The value to compare to.</param> /// <returns>True iff the two values represent the same value.</returns> public bool Equals(UInt48 other) { return _mostSignificant == other._mostSignificant && _leastSignificant == other._leastSignificant; }
public static void AssertValue(this XElement element, UInt48 expectedValue) { element.AssertValue(expectedValue.ToString("x12")); }
public static UInt48 Parse(string value, NumberStyles style) { return(UInt48.Parse(value, style, (IFormatProvider)CultureInfo.CurrentCulture.NumberFormat)); }
public static UInt48 Parse(string value, IFormatProvider provider) { return(UInt48.Parse(value, NumberStyles.Integer, provider)); }
public static UInt48 Parse(string value) { return(UInt48.Parse(value, NumberStyles.Integer, (IFormatProvider)CultureInfo.CurrentCulture)); }
/// <summary> /// Returns true iff the two values represent the same value. /// </summary> /// <param name="other">The value to compare to.</param> /// <returns>True iff the two values represent the same value.</returns> public bool Equals(UInt48 other) { return(_mostSignificant == other._mostSignificant && _leastSignificant == other._leastSignificant); }