The Open Toolkit library  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
OpenTK.Half Struct Reference

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...

Inherits ISerializable, IComparable< Half >, IFormattable, and IEquatable< Half >.

Public Member Functions

 Half (Single f)
 The new Half instance will convert the parameter into 16-bit half-precision floating-point. More...
 
 Half (Single f, bool throwOnError)
 The new Half instance will convert the parameter into 16-bit half-precision floating-point. More...
 
 Half (Double d)
 The new Half instance will convert the parameter into 16-bit half-precision floating-point. More...
 
 Half (Double d, bool throwOnError)
 The new Half instance will convert the parameter into 16-bit half-precision floating-point. More...
 
Single ToSingle ()
 Converts the 16-bit half to 32-bit floating-point. More...
 
 Half (SerializationInfo info, StreamingContext context)
 Constructor used by ISerializable to deserialize the object. More...
 
void GetObjectData (SerializationInfo info, StreamingContext context)
 Used by ISerialize to serialize the object. More...
 
void FromBinaryStream (BinaryReader bin)
 Updates the Half by reading from a Stream. More...
 
void ToBinaryStream (BinaryWriter bin)
 Writes the Half into a Stream. More...
 
bool Equals (Half other)
 Returns a value indicating whether this instance is equal to a specified OpenTK.Half value. More...
 
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. More...
 
override string ToString ()
 Converts this Half into a human-legible string representation. More...
 
string ToString (string format, IFormatProvider formatProvider)
 Converts this Half into a human-legible string representation. More...
 

Static Public Member Functions

static operator Half (float f)
 Converts a System.Single to a OpenTK.Half. More...
 
static operator Half (double d)
 Converts a System.Double to a OpenTK.Half. More...
 
static implicit operator float (Half h)
 Converts a OpenTK.Half to a System.Single. More...
 
static implicit operator double (Half h)
 Converts a OpenTK.Half to a System.Double. More...
 
static Half Parse (string s)
 Converts the string representation of a number to a half-precision floating-point equivalent. More...
 
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. More...
 
static bool TryParse (string s, out Half result)
 Converts the string representation of a number to a half-precision floating-point equivalent. Returns success. More...
 
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. More...
 
static byte[] GetBytes (Half h)
 Returns the Half as an array of bytes. More...
 
static Half FromBytes (byte[] value, int startIndex)
 Converts an array of bytes into Half. More...
 

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. More...
 
static readonly Single MinValue = 5.96046448e-08f
 Smallest positive half More...
 
static readonly Single MinNormalizedValue = 6.10351562e-05f
 Smallest positive normalized half More...
 
static readonly Single MaxValue = 65504.0f
 Largest positive half More...
 
static readonly Single Epsilon = 0.00097656f
 Smallest positive e for which half (1.0 + e) != half (1.0) More...
 

Properties

bool IsZero [get]
 Returns true if the Half is zero. More...
 
bool IsNaN [get]
 Returns true if the Half represents Not A Number (NaN) More...
 
bool IsPositiveInfinity [get]
 Returns true if the Half represents positive infinity. More...
 
bool IsNegativeInfinity [get]
 Returns true if the Half represents negative infinity. More...
 

Detailed Description

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.

Constructor & Destructor Documentation

OpenTK.Half.Half ( Single  f)

The new Half instance will convert the parameter into 16-bit half-precision floating-point.

Parameters
f32-bit single-precision floating-point number.
OpenTK.Half.Half ( Single  f,
bool  throwOnError 
)

The new Half instance will convert the parameter into 16-bit half-precision floating-point.

Parameters
f32-bit single-precision floating-point number.
throwOnErrorEnable checks that will throw if the conversion result is not meaningful.
OpenTK.Half.Half ( Double  d)

The new Half instance will convert the parameter into 16-bit half-precision floating-point.

Parameters
d64-bit double-precision floating-point number.
OpenTK.Half.Half ( Double  d,
bool  throwOnError 
)

The new Half instance will convert the parameter into 16-bit half-precision floating-point.

Parameters
d64-bit double-precision floating-point number.
throwOnErrorEnable checks that will throw if the conversion result is not meaningful.
OpenTK.Half.Half ( SerializationInfo  info,
StreamingContext  context 
)

Constructor used by ISerializable to deserialize the object.

Parameters
info
context

Member Function Documentation

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.

Parameters
otherA half-precision floating-point number to compare.
Returns

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.

Parameters
otherOpenTK.Half object to compare to this instance..
Returns
True, if other is equal to this instance; false otherwise.
void OpenTK.Half.FromBinaryStream ( BinaryReader  bin)

Updates the Half by reading from a Stream.

Parameters
binA BinaryReader instance associated with an open Stream.
static Half OpenTK.Half.FromBytes ( byte[]  value,
int  startIndex 
)
static

Converts an array of bytes into Half.

Parameters
valueA Half in it's byte[] representation.
startIndexThe starting position within value.
Returns
A new Half instance.
static byte [] OpenTK.Half.GetBytes ( Half  h)
static

Returns the Half as an array of bytes.

Parameters
hThe Half to convert.
Returns
The input as byte array.
void OpenTK.Half.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)

Used by ISerialize to serialize the object.

Parameters
info
context
static implicit OpenTK.Half.operator double ( Half  h)
static

Converts a OpenTK.Half to a System.Double.

Parameters
hThe value to convert. A Half
Returns
The result of the conversion. A System.Double
static implicit OpenTK.Half.operator float ( Half  h)
static

Converts a OpenTK.Half to a System.Single.

Parameters
hThe value to convert. A Half
Returns
The result of the conversion. A System.Single
static OpenTK.Half.operator Half ( float  f)
explicitstatic

Converts a System.Single to a OpenTK.Half.

Parameters
fThe value to convert. A System.Single
Returns
The result of the conversion. A Half
static OpenTK.Half.operator Half ( double  d)
explicitstatic

Converts a System.Double to a OpenTK.Half.

Parameters
dThe value to convert. A System.Double
Returns
The result of the conversion. A Half
static Half OpenTK.Half.Parse ( string  s)
static

Converts the string representation of a number to a half-precision floating-point equivalent.

Parameters
sString representation of the number to convert.
Returns
A new Half instance.
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.

Parameters
sString representation of the number to convert.
styleSpecifies the format of s.
providerCulture-specific formatting information.
Returns
A new Half instance.
void OpenTK.Half.ToBinaryStream ( BinaryWriter  bin)

Writes the Half into a Stream.

Parameters
binA BinaryWriter instance associated with an open Stream.
Single OpenTK.Half.ToSingle ( )

Converts the 16-bit half to 32-bit floating-point.

Returns
A single-precision floating-point number.
override string OpenTK.Half.ToString ( )

Converts this Half into a human-legible string representation.

Returns
The string representation of this instance.
string OpenTK.Half.ToString ( string  format,
IFormatProvider  formatProvider 
)

Converts this Half into a human-legible string representation.

Parameters
formatFormatting for the output string.
formatProviderCulture-specific formatting information.
Returns
The string representation of this instance.
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.

Parameters
sString representation of the number to convert.
resultThe Half instance to write to.
Returns
Success.
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.

Parameters
sString representation of the number to convert.
styleSpecifies the format of s.
providerCulture-specific formatting information.
resultThe Half instance to write to.
Returns
Success.

Member Data Documentation

readonly Single OpenTK.Half.Epsilon = 0.00097656f
static

Smallest positive e for which half (1.0 + e) != half (1.0)

readonly Single OpenTK.Half.MaxValue = 65504.0f
static

Largest positive half

readonly Single OpenTK.Half.MinNormalizedValue = 6.10351562e-05f
static

Smallest positive normalized half

readonly Single OpenTK.Half.MinValue = 5.96046448e-08f
static

Smallest positive half

readonly Int32 OpenTK.Half.SizeInBytes = 2
static

The size in bytes for an instance of the Half struct.

Property Documentation

bool OpenTK.Half.IsNaN
get

Returns true if the Half represents Not A Number (NaN)

bool OpenTK.Half.IsNegativeInfinity
get

Returns true if the Half represents negative infinity.

bool OpenTK.Half.IsPositiveInfinity
get

Returns true if the Half represents positive infinity.

bool OpenTK.Half.IsZero
get

Returns true if the Half is zero.