|
BitwiseCastToInt16 Method
|
Performs proper bitwise conversion between unsigned and signed value
Namespace: GSFAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.232-beta+203aa83a5a82d50f387e69875549969ad138d6e0
SyntaxPublic Shared Function ToInt16 (
unsignedInt As UShort
) As Short
GSF.BitwiseCast.ToInt16 = function(unsignedInt);
View SourceParameters
- unsignedInt UInt16
- Unsigned short that is passed in to be converted to a signed short.
Return Value
Int16The converted short value.
RemarksThis 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