Click or drag to resize

BitwiseCast.ToInt16 Method

Performs proper bitwise conversion between unsigned and signed value

Namespace: GSF
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.244-beta+cf93f5f8aea4b941e9b426fe4e180c2bd85d31a2
Syntax
public static short ToInt16(
	ushort unsignedInt
)
View Source

Parameters

unsignedInt  UInt16
Unsigned short that is passed in to be converted to a signed short.

Return Value

Int16
The converted short value.
Remarks

This function is useful because Convert.ToInt16 will throw an OverflowException for values greater than Int16.MaxValue.

For example, this function correctly converts unsigned 16-bit integer 65535 (i.e., UInt16.MaxValue) to signed 16-bit integer -1.

See Also