C# Class Evbpc.Framework.Utilities.Extensions.NumericExtensions

A collection of methods which may be used to assist in conversions from certain numeric types to others.
Show file Open project: EBrown8534/Framework

Public Methods

Method Description
FloatToUInt16 ( float value, byte decimalBits ) : ushort

Converts a float value to a rounded ushort, with the specified number of decimals.

GetUShortMask ( byte bits ) : ushort

Constructs a mask which can be used for FloatToUInt16(float, byte) and UInt16ToFloat(ushort, byte).

UInt16ToFloat ( ushort value, byte decimalBits ) : float

Converts a rounded ushort value to a float, with the specified number of decimals.

Method Details

FloatToUInt16() public static method

Converts a float value to a rounded ushort, with the specified number of decimals.
public static FloatToUInt16 ( float value, byte decimalBits ) : ushort
value float The float value to convert.
decimalBits byte The number of bits in the ushort value which represent decimals.
return ushort

GetUShortMask() public static method

Constructs a mask which can be used for FloatToUInt16(float, byte) and UInt16ToFloat(ushort, byte).
public static GetUShortMask ( byte bits ) : ushort
bits byte The number of bits that should be set in the mask.
return ushort

UInt16ToFloat() public static method

Converts a rounded ushort value to a float, with the specified number of decimals.
public static UInt16ToFloat ( ushort value, byte decimalBits ) : float
value ushort The ushort value to convert.
decimalBits byte The number of bits in the ushort value which represent decimals.
return float