The name Half is derived from half-precision floating-point number. It occupies only 16 bits, which are split into 1 Sign bit, 5 Exponent bits and 10 Mantissa bits. More...
Public Member Functions | |
| Half (Single f) | |
| The new Half instance will convert the parameter into 16-bit half-precision floating-point. | |
| Half (Single f, bool throwOnError) | |
| The new Half instance will convert the parameter into 16-bit half-precision floating-point. | |
| Half (Double d) | |
| The new Half instance will convert the parameter into 16-bit half-precision floating-point. | |
| Half (Double d, bool throwOnError) | |
| The new Half instance will convert the parameter into 16-bit half-precision floating-point. | |
| Single | ToSingle () |
| Converts the 16-bit half to 32-bit floating-point. | |
| Half (SerializationInfo info, StreamingContext context) | |
| Constructor used by ISerializable to deserialize the object. | |
| void | GetObjectData (SerializationInfo info, StreamingContext context) |
| Used by ISerialize to serialize the object. | |
| void | FromBinaryStream (BinaryReader bin) |
| Updates the Half by reading from a Stream. | |
| void | ToBinaryStream (BinaryWriter bin) |
| Writes the Half into a Stream. | |
| bool | Equals (Half other) |
| Returns a value indicating whether this instance is equal to a specified OpenTK.Half value. | |
| int | CompareTo (Half other) |
| Compares this instance to a specified half-precision floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified half-precision floating-point number. | |
| override string | ToString () |
| Converts this Half into a human-legible string representation. | |
| string | ToString (string format, IFormatProvider formatProvider) |
| Converts this Half into a human-legible string representation. | |
Static Public Member Functions | |
| static | operator Half (float f) |
| Converts a System.Single to a OpenTK.Half. | |
| static | operator Half (double d) |
| Converts a System.Double to a OpenTK.Half. | |
| static implicit | operator float (Half h) |
| Converts a OpenTK.Half to a System.Single. | |
| static implicit | operator double (Half h) |
| Converts a OpenTK.Half to a System.Double. | |
| static Half | Parse (string s) |
| Converts the string representation of a number to a half-precision floating-point equivalent. | |
| static Half | Parse (string s, System.Globalization.NumberStyles style, IFormatProvider provider) |
| Converts the string representation of a number to a half-precision floating-point equivalent. | |
| static bool | TryParse (string s, out Half result) |
| Converts the string representation of a number to a half-precision floating-point equivalent. Returns success. | |
| static bool | TryParse (string s, System.Globalization.NumberStyles style, IFormatProvider provider, out Half result) |
| Converts the string representation of a number to a half-precision floating-point equivalent. Returns success. | |
| static byte[] | GetBytes (Half h) |
| Returns the Half as an array of bytes. | |
| static Half | FromBytes (byte[] value, int startIndex) |
| Converts an array of bytes into Half. | |
Public Attributes | |
| UInt16 | bits |
| const int | maxUlps = 1 |
Static Public Attributes | |
| static readonly Int32 | SizeInBytes = 2 |
| The size in bytes for an instance of the Half struct. | |
| static readonly Single | MinValue = 5.96046448e-08f |
| Smallest positive half. | |
| static readonly Single | MinNormalizedValue = 6.10351562e-05f |
| Smallest positive normalized half. | |
| static readonly Single | MaxValue = 65504.0f |
| Largest positive half. | |
| static readonly Single | Epsilon = 0.00097656f |
| Smallest positive e for which half (1.0 + e) != half (1.0). | |
Properties | |
| bool | IsZero [get] |
| Returns true if the Half is zero. | |
| bool | IsNaN [get] |
| Returns true if the Half represents Not A Number (NaN). | |
| bool | IsPositiveInfinity [get] |
| Returns true if the Half represents positive infinity. | |
| bool | IsNegativeInfinity [get] |
| Returns true if the Half represents negative infinity. | |
The name Half is derived from half-precision floating-point number. It occupies only 16 bits, which are split into 1 Sign bit, 5 Exponent bits and 10 Mantissa bits.
Quote from ARB_half_float_pixel specification: Any representable 16-bit floating-point value is legal as input to a GL command that accepts 16-bit floating-point data. The result of providing a value that is not a floating-point number (such as infinity or NaN) to such a command is unspecified, but must not lead to GL interruption or termination. Providing a denormalized number or negative zero to GL must yield predictable results.
Definition at line 79 of file Half.cs.
| OpenTK.Half.Half | ( | Single | f | ) |
| OpenTK.Half.Half | ( | Single | f, | |
| bool | throwOnError | |||
| ) |
The new Half instance will convert the parameter into 16-bit half-precision floating-point.
| f | 32-bit single-precision floating-point number. | |
| throwOnError | Enable checks that will throw if the conversion result is not meaningful. |
Definition at line 123 of file Half.cs.
00124 : this(f) 00125 { 00126 if (throwOnError) 00127 { 00128 // handle cases that cause overflow rather than silently ignoring it 00129 if (f > Half.MaxValue) throw new ArithmeticException("Half: Positive maximum value exceeded."); 00130 if (f < -Half.MaxValue) throw new ArithmeticException("Half: Negative minimum value exceeded."); 00131 00132 // handle cases that make no sense 00133 if (Single.IsNaN(f)) throw new ArithmeticException("Half: Input is not a number (NaN)."); 00134 if (Single.IsPositiveInfinity(f)) throw new ArithmeticException("Half: Input is positive infinity."); 00135 if (Single.IsNegativeInfinity(f)) throw new ArithmeticException("Half: Input is negative infinity."); 00136 } 00137 }
| OpenTK.Half.Half | ( | Double | d | ) |
| OpenTK.Half.Half | ( | Double | d, | |
| bool | throwOnError | |||
| ) |
The new Half instance will convert the parameter into 16-bit half-precision floating-point.
| d | 64-bit double-precision floating-point number. | |
| throwOnError | Enable checks that will throw if the conversion result is not meaningful. |
| OpenTK.Half.Half | ( | SerializationInfo | info, | |
| StreamingContext | context | |||
| ) |
| int OpenTK.Half.CompareTo | ( | Half | other | ) |
Compares this instance to a specified half-precision floating-point number and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified half-precision floating-point number.
| other | A half-precision floating-point number to compare. |
A signed number indicating the relative values of this instance and value. If the number is:
Less than zero, then this instance is less than other, or this instance is not a number (OpenTK.Half.NaN) and other is a number.
Zero: this instance is equal to value, or both this instance and other are not a number (OpenTK.Half.NaN), OpenTK.Half.PositiveInfinity, or OpenTK.Half.NegativeInfinity.
Greater than zero: this instance is greater than othrs, or this instance is a number and other is not a number (OpenTK.Half.NaN).
| bool OpenTK.Half.Equals | ( | Half | other | ) |
Returns a value indicating whether this instance is equal to a specified OpenTK.Half value.
| other | OpenTK.Half object to compare to this instance.. |
Definition at line 447 of file Half.cs.
00448 { 00449 short aInt, bInt; 00450 unchecked { aInt = (short)other.bits; } 00451 unchecked { bInt = (short)this.bits; } 00452 00453 // Make aInt lexicographically ordered as a twos-complement int 00454 if (aInt < 0) 00455 aInt = (short)(0x8000 - aInt); 00456 00457 // Make bInt lexicographically ordered as a twos-complement int 00458 if (bInt < 0) 00459 bInt = (short)(0x8000 - bInt); 00460 00461 short intDiff = System.Math.Abs((short)(aInt - bInt)); 00462 00463 if (intDiff <= maxUlps) 00464 return true; 00465 00466 return false; 00467 }
| void OpenTK.Half.FromBinaryStream | ( | BinaryReader | bin | ) |
| static Half OpenTK.Half.FromBytes | ( | byte[] | value, | |
| int | startIndex | |||
| ) | [static] |
Converts an array of bytes into Half.
| value | A Half in it's byte[] representation. | |
| startIndex | The starting position within value. |
Definition at line 579 of file Half.cs.
00580 { 00581 Half h; 00582 h.bits = BitConverter.ToUInt16(value, startIndex); 00583 return h; 00584 }
| static byte [] OpenTK.Half.GetBytes | ( | Half | h | ) | [static] |
| void OpenTK.Half.GetObjectData | ( | SerializationInfo | info, | |
| StreamingContext | context | |||
| ) |
| static implicit OpenTK.Half.operator double | ( | Half | h | ) | [static] |
Converts a OpenTK.Half to a System.Double.
| h | The value to convert. A Half |
| static implicit OpenTK.Half.operator float | ( | Half | h | ) | [static] |
Converts a OpenTK.Half to a System.Single.
| h | The value to convert. A Half |
| static OpenTK.Half.operator Half | ( | double | d | ) | [explicit, static] |
Converts a System.Double to a OpenTK.Half.
| d | The value to convert. A System.Double |
Definition at line 345 of file Half.cs.
00346 { 00347 return new Half(d); 00348 }
| static OpenTK.Half.operator Half | ( | float | f | ) | [explicit, static] |
Converts a System.Single to a OpenTK.Half.
| f | The value to convert. A System.Single |
Definition at line 331 of file Half.cs.
00332 { 00333 return new Half(f); 00334 }
| static Half OpenTK.Half.Parse | ( | string | s, | |
| System.Globalization.NumberStyles | style, | |||
| IFormatProvider | provider | |||
| ) | [static] |
Converts the string representation of a number to a half-precision floating-point equivalent.
| s | String representation of the number to convert. | |
| style | Specifies the format of s. | |
| provider | Culture-specific formatting information. |
Definition at line 532 of file Half.cs.
00533 { 00534 return (Half)Single.Parse(s, style, provider); 00535 }
| static Half OpenTK.Half.Parse | ( | string | s | ) | [static] |
| void OpenTK.Half.ToBinaryStream | ( | BinaryWriter | bin | ) |
| Single OpenTK.Half.ToSingle | ( | ) |
| string OpenTK.Half.ToString | ( | string | format, | |
| IFormatProvider | formatProvider | |||
| ) |
Converts this Half into a human-legible string representation.
| format | Formatting for the output string. | |
| formatProvider | Culture-specific formatting information. |
Definition at line 510 of file Half.cs.
00511 { 00512 return this.ToSingle().ToString(format, formatProvider); 00513 }
| override string OpenTK.Half.ToString | ( | ) |
| static bool OpenTK.Half.TryParse | ( | string | s, | |
| System.Globalization.NumberStyles | style, | |||
| IFormatProvider | provider, | |||
| out Half | result | |||
| ) | [static] |
Converts the string representation of a number to a half-precision floating-point equivalent. Returns success.
| s | String representation of the number to convert. | |
| style | Specifies the format of s. | |
| provider | Culture-specific formatting information. | |
| result | The Half instance to write to. |
Definition at line 555 of file Half.cs.
00556 { 00557 float f; 00558 bool b = Single.TryParse(s, style, provider, out f); 00559 result = (Half)f; 00560 return b; 00561 }
| static bool OpenTK.Half.TryParse | ( | string | s, | |
| out Half | result | |||
| ) | [static] |
Converts the string representation of a number to a half-precision floating-point equivalent. Returns success.
| s | String representation of the number to convert. | |
| result | The Half instance to write to. |
Definition at line 541 of file Half.cs.
00542 { 00543 float f; 00544 bool b = Single.TryParse(s, out f); 00545 result = (Half)f; 00546 return b; 00547 }
readonly Single OpenTK.Half.Epsilon = 0.00097656f [static] |
readonly Single OpenTK.Half.MaxValue = 65504.0f [static] |
readonly Single OpenTK.Half.MinNormalizedValue = 6.10351562e-05f [static] |
readonly Single OpenTK.Half.MinValue = 5.96046448e-08f [static] |
readonly Int32 OpenTK.Half.SizeInBytes = 2 [static] |
bool OpenTK.Half.IsNaN [get] |
bool OpenTK.Half.IsNegativeInfinity [get] |
bool OpenTK.Half.IsPositiveInfinity [get] |
1.6.1