My Project
|
Represents a half-precision floating point number. More...
Public Member Functions | |
Half (float value) | |
Initializes a new instance of System.Half to the value of the specified single-precision floating-point number. | |
Half (int value) | |
Initializes a new instance of System.Half to the value of the specified 32-bit signed integer. | |
Half (long value) | |
Initializes a new instance of System.Half to the value of the specified 64-bit signed integer. | |
Half (double value) | |
Initializes a new instance of System.Half to the value of the specified double-precision floating-point number. | |
Half (decimal value) | |
Initializes a new instance of System.Half to the value of the specified decimal number. | |
Half (uint value) | |
Initializes a new instance of System.Half to the value of the specified 32-bit unsigned integer. | |
Half (ulong value) | |
Initializes a new instance of System.Half to the value of the specified 64-bit unsigned integer. | |
int | CompareTo (Half other) |
Compares this instance to a specified System.Half object. | |
int | CompareTo (object obj) |
Compares this instance to a specified System.Object. | |
bool | Equals (Half other) |
Returns a value indicating whether this instance and a specified System.Half object represent the same value. | |
override bool | Equals (object obj) |
Returns a value indicating whether this instance and a specified System.Object represent the same type and value. | |
override int | GetHashCode () |
Returns the hash code for this instance. | |
TypeCode | GetTypeCode () |
Returns the System.TypeCode for value type System.Half. | |
override string | ToString () |
Converts the numeric value of this instance to its equivalent string representation. | |
string | ToString (IFormatProvider formatProvider) |
Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. | |
string | ToString (string format) |
Converts the numeric value of this instance to its equivalent string representation, using the specified format. | |
string | ToString (string format, IFormatProvider formatProvider) |
Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information. | |
float IConvertible. | ToSingle (IFormatProvider provider) |
TypeCode IConvertible. | GetTypeCode () |
bool IConvertible. | ToBoolean (IFormatProvider provider) |
byte IConvertible. | ToByte (IFormatProvider provider) |
char IConvertible. | ToChar (IFormatProvider provider) |
DateTime IConvertible. | ToDateTime (IFormatProvider provider) |
decimal IConvertible. | ToDecimal (IFormatProvider provider) |
double IConvertible. | ToDouble (IFormatProvider provider) |
short IConvertible. | ToInt16 (IFormatProvider provider) |
int IConvertible. | ToInt32 (IFormatProvider provider) |
long IConvertible. | ToInt64 (IFormatProvider provider) |
sbyte IConvertible. | ToSByte (IFormatProvider provider) |
string IConvertible. | ToString (IFormatProvider provider) |
object IConvertible. | ToType (Type conversionType, IFormatProvider provider) |
ushort IConvertible. | ToUInt16 (IFormatProvider provider) |
uint IConvertible. | ToUInt32 (IFormatProvider provider) |
ulong IConvertible. | ToUInt64 (IFormatProvider provider) |
Static Public Member Functions | |
static Half | Negate (Half half) |
Returns the result of multiplying the specified System.Half value by negative one. | |
static Half | Add (Half half1, Half half2) |
Adds two specified System.Half values. | |
static Half | Subtract (Half half1, Half half2) |
Subtracts one specified System.Half value from another. | |
static Half | Multiply (Half half1, Half half2) |
Multiplies two specified System.Half values. | |
static Half | Divide (Half half1, Half half2) |
Divides two specified System.Half values. | |
static Half | operator+ (Half half) |
Returns the value of the System.Half operand (the sign of the operand is unchanged). | |
static Half | operator- (Half half) |
Negates the value of the specified System.Half operand. | |
static Half | operator++ (Half half) |
Increments the System.Half operand by 1. | |
static Half | operator-- (Half half) |
Decrements the System.Half operand by one. | |
static Half | operator+ (Half half1, Half half2) |
Adds two specified System.Half values. | |
static Half | operator- (Half half1, Half half2) |
Subtracts two specified System.Half values. | |
static Half | operator* (Half half1, Half half2) |
Multiplies two specified System.Half values. | |
static Half | operator/ (Half half1, Half half2) |
Divides two specified System.Half values. | |
static bool | operator== (Half half1, Half half2) |
Returns a value indicating whether two instances of System.Half are equal. | |
static bool | operator!= (Half half1, Half half2) |
Returns a value indicating whether two instances of System.Half are not equal. | |
static bool | operator< (Half half1, Half half2) |
Returns a value indicating whether a specified System.Half is less than another specified System.Half. | |
static bool | operator> (Half half1, Half half2) |
Returns a value indicating whether a specified System.Half is greater than another specified System.Half. | |
static bool | operator<= (Half half1, Half half2) |
Returns a value indicating whether a specified System.Half is less than or equal to another specified System.Half. | |
static bool | operator>= (Half half1, Half half2) |
Returns a value indicating whether a specified System.Half is greater than or equal to another specified System.Half. | |
static implicit | operator Half (byte value) |
Converts an 8-bit unsigned integer to a System.Half. | |
static implicit | operator Half (short value) |
Converts a 16-bit signed integer to a System.Half. | |
static implicit | operator Half (char value) |
Converts a Unicode character to a System.Half. | |
static implicit | operator Half (int value) |
Converts a 32-bit signed integer to a System.Half. | |
static implicit | operator Half (long value) |
Converts a 64-bit signed integer to a System.Half. | |
static | operator Half (float value) |
Converts a single-precision floating-point number to a System.Half. | |
static | operator Half (double value) |
Converts a double-precision floating-point number to a System.Half. | |
static | operator Half (decimal value) |
Converts a decimal number to a System.Half. | |
static | operator byte (Half value) |
Converts a System.Half to an 8-bit unsigned integer. | |
static | operator char (Half value) |
Converts a System.Half to a Unicode character. | |
static | operator short (Half value) |
Converts a System.Half to a 16-bit signed integer. | |
static | operator int (Half value) |
Converts a System.Half to a 32-bit signed integer. | |
static | operator long (Half value) |
Converts a System.Half to a 64-bit signed integer. | |
static implicit | operator float (Half value) |
Converts a System.Half to a single-precision floating-point number. | |
static implicit | operator double (Half value) |
Converts a System.Half to a double-precision floating-point number. | |
static | operator decimal (Half value) |
Converts a System.Half to a decimal number. | |
static implicit | operator Half (sbyte value) |
Converts an 8-bit signed integer to a System.Half. | |
static implicit | operator Half (ushort value) |
Converts a 16-bit unsigned integer to a System.Half. | |
static implicit | operator Half (uint value) |
Converts a 32-bit unsigned integer to a System.Half. | |
static implicit | operator Half (ulong value) |
Converts a 64-bit unsigned integer to a System.Half. | |
static | operator sbyte (Half value) |
Converts a System.Half to an 8-bit signed integer. | |
static | operator ushort (Half value) |
Converts a System.Half to a 16-bit unsigned integer. | |
static | operator uint (Half value) |
Converts a System.Half to a 32-bit unsigned integer. | |
static | operator ulong (Half value) |
Converts a System.Half to a 64-bit unsigned integer. | |
static byte[] | GetBytes (Half value) |
Returns the specified half-precision floating point value as an array of bytes. | |
static ushort | GetBits (Half value) |
Converts the value of a specified instance of System.Half to its equivalent binary representation. | |
static Half | ToHalf (byte[] value, int startIndex) |
Returns a half-precision floating point number converted from two bytes at a specified position in a byte array. | |
static Half | ToHalf (ushort bits) |
Returns a half-precision floating point number converted from its binary representation. | |
static int | Sign (Half value) |
Returns a value indicating the sign of a half-precision floating-point number. | |
static Half | Abs (Half value) |
Returns the absolute value of a half-precision floating-point number. | |
static Half | Max (Half value1, Half value2) |
Returns the larger of two half-precision floating-point numbers. | |
static Half | Min (Half value1, Half value2) |
Returns the smaller of two half-precision floating-point numbers. | |
static bool | IsNaN (Half half) |
Returns a value indicating whether the specified number evaluates to not a number (System.Half.NaN). | |
static bool | IsInfinity (Half half) |
Returns a value indicating whether the specified number evaluates to negative or positive infinity. | |
static bool | IsNegativeInfinity (Half half) |
Returns a value indicating whether the specified number evaluates to negative infinity. | |
static bool | IsPositiveInfinity (Half half) |
Returns a value indicating whether the specified number evaluates to positive infinity. | |
static Half | Parse (string value) |
Converts the string representation of a number to its System.Half equivalent. | |
static Half | Parse (string value, IFormatProvider provider) |
Converts the string representation of a number to its System.Half equivalent using the specified culture-specific format information. | |
static Half | Parse (string value, NumberStyles style) |
Converts the string representation of a number in a specified style to its System.Half equivalent. | |
static Half | Parse (string value, NumberStyles style, IFormatProvider provider) |
Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format. | |
static bool | TryParse (string value, out Half result) |
Converts the string representation of a number to its System.Half equivalent. A return value indicates whether the conversion succeeded or failed. | |
static bool | TryParse (string value, NumberStyles style, IFormatProvider provider, out Half result) |
Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed. | |
Public Attributes | |
ushort | internalValue |
Internal representation of the half-precision floating-point number. | |
Static Public Attributes | |
static readonly Half | Epsilon = Half.ToHalf(0x0001) |
Represents the smallest positive System.Half value greater than zero. This field is constant. | |
static readonly Half | MaxValue = Half.ToHalf(0x7bff) |
Represents the largest possible value of System.Half. This field is constant. | |
static readonly Half | MinValue = Half.ToHalf(0xfbff) |
Represents the smallest possible value of System.Half. This field is constant. | |
static readonly Half | NaN = Half.ToHalf(0xfe00) |
Represents not a number (NaN). This field is constant. | |
static readonly Half | NegativeInfinity = Half.ToHalf(0xfc00) |
Represents negative infinity. This field is constant. | |
static readonly Half | PositiveInfinity = Half.ToHalf(0x7c00) |
Represents positive infinity. This field is constant. | |
Represents a half-precision floating point number.
Note: Half is not fast enough and precision is also very bad, so it should not be used for matemathical computation (use Single instead). The main advantage of Half type is lower memory cost: two bytes per number. Half is typically used in graphical applications.
Note: All functions, where is used conversion half->float/float->half, are approx. ten times slower than float->double/double->float, i.e. ~3ns on 2GHz CPU.
References:
|
inline |
Initializes a new instance of System.Half to the value of the specified single-precision floating-point number.
value | The value to represent as a System.Half. |
|
inline |
Initializes a new instance of System.Half to the value of the specified 32-bit signed integer.
value | The value to represent as a System.Half. |
|
inline |
Initializes a new instance of System.Half to the value of the specified 64-bit signed integer.
value | The value to represent as a System.Half. |
|
inline |
Initializes a new instance of System.Half to the value of the specified double-precision floating-point number.
value | The value to represent as a System.Half. |
|
inline |
Initializes a new instance of System.Half to the value of the specified decimal number.
value | The value to represent as a System.Half. |
|
inline |
Initializes a new instance of System.Half to the value of the specified 32-bit unsigned integer.
value | The value to represent as a System.Half. |
|
inline |
Initializes a new instance of System.Half to the value of the specified 64-bit unsigned integer.
value | The value to represent as a System.Half. |
Returns the absolute value of a half-precision floating-point number.
value | A number in the range System.Half.MinValue ≤ value ≤ System.Half.MaxValue. |
Adds two specified System.Half values.
half1 | A System.Half. |
half2 | A System.Half. |
|
inline |
Compares this instance to a specified System.Half object.
other | A System.Half object. |
|
inline |
Compares this instance to a specified System.Object.
obj | An System.Object or null. |
System.ArgumentException | value is not a System.Half |
Divides two specified System.Half values.
half1 | A System.Half (the dividend). |
half2 | A System.Half (the divisor). |
System.DivideByZeroException | half2 is zero. |
|
inline |
Returns a value indicating whether this instance and a specified System.Half object represent the same value.
other | A System.Half object to compare to this instance. |
|
inline |
Returns a value indicating whether this instance and a specified System.Object represent the same type and value.
obj | An System.Object. |
|
inlinestatic |
Converts the value of a specified instance of System.Half to its equivalent binary representation.
value | A System.Half value. |
|
inlinestatic |
Returns the specified half-precision floating point value as an array of bytes.
value | The number to convert. |
|
inline |
Returns the hash code for this instance.
|
inline |
Returns the System.TypeCode for value type System.Half.
|
inlinestatic |
Returns a value indicating whether the specified number evaluates to negative or positive infinity.
half | A half-precision floating-point number. |
|
inlinestatic |
Returns a value indicating whether the specified number evaluates to not a number (System.Half.NaN).
half | A half-precision floating-point number. |
|
inlinestatic |
Returns a value indicating whether the specified number evaluates to negative infinity.
half | A half-precision floating-point number. |
|
inlinestatic |
Returns a value indicating whether the specified number evaluates to positive infinity.
half | A half-precision floating-point number. |
Returns the larger of two half-precision floating-point numbers.
value1 | The first of two half-precision floating-point numbers to compare. |
value2 | The second of two half-precision floating-point numbers to compare. |
Returns the smaller of two half-precision floating-point numbers.
value1 | The first of two half-precision floating-point numbers to compare. |
value2 | The second of two half-precision floating-point numbers to compare. |
Multiplies two specified System.Half values.
half1 | A System.Half (the multiplicand). |
half2 | A System.Half (the multiplier). |
Returns the result of multiplying the specified System.Half value by negative one.
half | A System.Half. |
|
inlineexplicitstatic |
Converts a System.Half to an 8-bit unsigned integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a Unicode character.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a decimal number.
value | A System.Half to convert. |
|
inlinestatic |
Converts a System.Half to a double-precision floating-point number.
value | A System.Half to convert. |
|
inlinestatic |
Converts a System.Half to a single-precision floating-point number.
value | A System.Half to convert. |
|
inlinestatic |
Converts an 8-bit unsigned integer to a System.Half.
value | An 8-bit unsigned integer. |
|
inlinestatic |
Converts a Unicode character to a System.Half.
value | A Unicode character. |
|
inlineexplicitstatic |
Converts a decimal number to a System.Half.
value | decimal number |
|
inlineexplicitstatic |
Converts a double-precision floating-point number to a System.Half.
value | A double-precision floating-point number. |
|
inlineexplicitstatic |
Converts a single-precision floating-point number to a System.Half.
value | A single-precision floating-point number. |
|
inlinestatic |
Converts a 32-bit signed integer to a System.Half.
value | A 32-bit signed integer. |
|
inlinestatic |
Converts a 64-bit signed integer to a System.Half.
value | A 64-bit signed integer. |
|
inlinestatic |
Converts an 8-bit signed integer to a System.Half.
value | An 8-bit signed integer. |
|
inlinestatic |
Converts a 16-bit signed integer to a System.Half.
value | A 16-bit signed integer. |
|
inlinestatic |
Converts a 32-bit unsigned integer to a System.Half.
value | A 32-bit unsigned integer. |
|
inlinestatic |
Converts a 64-bit unsigned integer to a System.Half.
value | A 64-bit unsigned integer. |
|
inlinestatic |
Converts a 16-bit unsigned integer to a System.Half.
value | A 16-bit unsigned integer. |
|
inlineexplicitstatic |
Converts a System.Half to a 32-bit signed integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a 64-bit signed integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to an 8-bit signed integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a 16-bit signed integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a 32-bit unsigned integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a 64-bit unsigned integer.
value | A System.Half to convert. |
|
inlineexplicitstatic |
Converts a System.Half to a 16-bit unsigned integer.
value | A System.Half to convert. |
Returns a value indicating whether two instances of System.Half are not equal.
half1 | A System.Half. |
half2 | A System.Half. |
Multiplies two specified System.Half values.
half1 | A System.Half. |
half2 | A System.Half. |
Returns the value of the System.Half operand (the sign of the operand is unchanged).
half | The System.Half operand. |
Adds two specified System.Half values.
half1 | A System.Half. |
half2 | A System.Half. |
Increments the System.Half operand by 1.
half | The System.Half operand. |
Negates the value of the specified System.Half operand.
half | The System.Half operand. |
Subtracts two specified System.Half values.
half1 | A System.Half. |
half2 | A System.Half. |
Decrements the System.Half operand by one.
half | The System.Half operand. |
Divides two specified System.Half values.
half1 | A System.Half (the dividend). |
half2 | A System.Half (the divisor). |
Returns a value indicating whether a specified System.Half is less than another specified System.Half.
half1 | A System.Half. |
half2 | A System.Half. |
Returns a value indicating whether a specified System.Half is less than or equal to another specified System.Half.
half1 | A System.Half. |
half2 | A System.Half. |
Returns a value indicating whether two instances of System.Half are equal.
half1 | A System.Half. |
half2 | A System.Half. |
Returns a value indicating whether a specified System.Half is greater than another specified System.Half.
half1 | A System.Half. |
half2 | A System.Half. |
Returns a value indicating whether a specified System.Half is greater than or equal to another specified System.Half.
half1 | A System.Half. |
half2 | A System.Half. |
|
inlinestatic |
Converts the string representation of a number to its System.Half equivalent.
value | The string representation of the number to convert. |
System.ArgumentNullException | value is null. |
System.FormatException | value is not in the correct format. |
System.OverflowException | value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue. |
|
inlinestatic |
Converts the string representation of a number to its System.Half equivalent using the specified culture-specific format information.
value | The string representation of the number to convert. |
provider | An System.IFormatProvider that supplies culture-specific parsing information about value. |
System.ArgumentNullException | value is null. |
System.FormatException | value is not in the correct format. |
System.OverflowException | value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue. |
|
inlinestatic |
Converts the string representation of a number in a specified style to its System.Half equivalent.
value | The string representation of the number to convert. |
style | A bitwise combination of System.Globalization.NumberStyles values that indicates the style elements that can be present in value. A typical value to specify is System.Globalization.NumberStyles.Number. |
System.ArgumentNullException | value is null. |
System.ArgumentException | style is not a System.Globalization.NumberStyles value. -or- style is the System.Globalization.NumberStyles.AllowHexSpecifier value. |
System.FormatException | value is not in the correct format. |
System.OverflowException | value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue. |
|
inlinestatic |
Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format.
value | The string representation of the number to convert. |
style | A bitwise combination of System.Globalization.NumberStyles values that indicates the style elements that can be present in value. A typical value to specify is System.Globalization.NumberStyles.Number. |
provider | An System.IFormatProvider object that supplies culture-specific information about the format of value. |
System.ArgumentNullException | value is null. |
System.ArgumentException | style is not a System.Globalization.NumberStyles value. -or- style is the System.Globalization.NumberStyles.AllowHexSpecifier value. |
System.FormatException | value is not in the correct format. |
System.OverflowException | value represents a number less than System.Half.MinValue or greater than System.Half.MaxValue. |
|
inlinestatic |
Returns a value indicating the sign of a half-precision floating-point number.
value | A signed number. |
System.ArithmeticException | value is equal to System.Half.NaN. |
Subtracts one specified System.Half value from another.
half1 | A System.Half (the minuend). |
half2 | A System.Half (the subtrahend). |
|
inlinestatic |
Returns a half-precision floating point number converted from two bytes at a specified position in a byte array.
value | An array of bytes. |
startIndex | The starting position within value. |
System.ArgumentException | startIndex is greater than or equal to the length of value minus 1, and is less than or equal to the length of value minus 1. |
System.ArgumentNullException | value is null. |
System.ArgumentOutOfRangeException | startIndex is less than zero or greater than the length of value minus 1. |
|
inlinestatic |
Returns a half-precision floating point number converted from its binary representation.
bits | Binary representation of System.Half value |
|
inline |
Converts the numeric value of this instance to its equivalent string representation.
|
inline |
Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
formatProvider | An System.IFormatProvider that supplies culture-specific formatting information. |
|
inline |
Converts the numeric value of this instance to its equivalent string representation, using the specified format.
format | A numeric format string. |
|
inline |
Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
format | A numeric format string. |
formatProvider | An System.IFormatProvider that supplies culture-specific formatting information. |
System.FormatException | format is invalid. |
|
inlinestatic |
Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format. A return value indicates whether the conversion succeeded or failed.
value | The string representation of the number to convert. |
style | A bitwise combination of System.Globalization.NumberStyles values that indicates the permitted format of value. A typical value to specify is System.Globalization.NumberStyles.Number. |
provider | An System.IFormatProvider object that supplies culture-specific parsing information about value. |
result | When this method returns, contains the System.Half number that is equivalent to the numeric value contained in value, if the conversion succeeded, or is zero if the conversion failed. The conversion fails if the s parameter is null, is not in a format compliant with style, or represents a number less than System.Half.MinValue or greater than System.Half.MaxValue. This parameter is passed uninitialized. |
System.ArgumentException | style is not a System.Globalization.NumberStyles value. -or- style is the System.Globalization.NumberStyles.AllowHexSpecifier value. |
|
inlinestatic |
Converts the string representation of a number to its System.Half equivalent. A return value indicates whether the conversion succeeded or failed.
value | The string representation of the number to convert. |
result | When this method returns, contains the System.Half number that is equivalent to the numeric value contained in value, if the conversion succeeded, or is zero if the conversion failed. The conversion fails if the s parameter is null, is not a number in a valid format, or represents a number less than System.Half.MinValue or greater than System.Half.MaxValue. This parameter is passed uninitialized. |