Click or drag to resize

HalfType Structure

Represents a half-precision floating point number.
Inheritance Hierarchy
SystemObject
  SystemValueType
    NeoAxisHalfType

Namespace: NeoAxis
Assembly: NeoAxis.Core (in NeoAxis.Core.dll) Version: 2026.1.1.0 (2026.1.1.0)
Syntax
C#
[SerializableAttribute]
public struct HalfType : IComparable, IFormattable, 
	IConvertible, IComparable<HalfType>, IEquatable<HalfType>

The HalfType type exposes the following members.

Constructors
 NameDescription
Public methodHalfType(Decimal) Initializes a new instance of System.Half to the value of the specified decimal number.
Public methodHalfType(Double) Initializes a new instance of System.Half to the value of the specified double-precision floating-point number.
Public methodHalfType(Int32) Initializes a new instance of System.Half to the value of the specified 32-bit signed integer.
Public methodHalfType(Int64) Initializes a new instance of System.Half to the value of the specified 64-bit signed integer.
Public methodHalfType(Single) Initializes a new instance of System.Half to the value of the specified single-precision floating-point number.
Public methodHalfType(UInt32) Initializes a new instance of System.Half to the value of the specified 32-bit unsigned integer.
Public methodHalfType(UInt64) Initializes a new instance of System.Half to the value of the specified 64-bit unsigned integer.
Top
Methods
 NameDescription
Public methodStatic memberAbs Returns the absolute value of a half-precision floating-point number.
Public methodStatic memberAdd Adds two specified System.Half values.
Public methodCompareTo(HalfType) Compares this instance to a specified System.Half object.
Public methodCompareTo(Object) Compares this instance to a specified System.Object.
Public methodStatic memberDivide Divides two specified System.Half values.
Public methodEquals(HalfType) Returns a value indicating whether this instance and a specified System.Half object represent the same value.
Public methodEquals(Object) Returns a value indicating whether this instance and a specified System.Object represent the same type and value.
(Overrides ValueTypeEquals(Object))
Public methodStatic memberGetBits Converts the value of a specified instance of System.Half to its equivalent binary representation.
Public methodStatic memberGetBytes Returns the specified half-precision floating point value as an array of bytes.
Public methodGetHashCode Returns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodGetTypeCode Returns the System.TypeCode for value type System.Half.
Public methodStatic memberIsInfinity Returns a value indicating whether the specified number evaluates to negative or positive infinity.
Public methodStatic memberIsNaN Returns a value indicating whether the specified number evaluates to not a number (System.Half.NaN).
Public methodStatic memberIsNegativeInfinity Returns a value indicating whether the specified number evaluates to negative infinity.
Public methodStatic memberIsPositiveInfinity Returns a value indicating whether the specified number evaluates to positive infinity.
Public methodStatic memberMax Returns the larger of two half-precision floating-point numbers.
Public methodStatic memberMin Returns the smaller of two half-precision floating-point numbers.
Public methodStatic memberMultiply Multiplies two specified System.Half values.
Public methodStatic memberNegate Returns the result of multiplying the specified System.Half value by negative one.
Public methodStatic memberPackTwoHalfsToFloat(HalfType, HalfType) 
Public methodStatic memberPackTwoHalfsToFloat(Single, Single) 
Public methodStatic memberParse(String) Converts the string representation of a number to its System.Half equivalent.
Public methodStatic memberParse(String, NumberStyles) Converts the string representation of a number in a specified style to its System.Half equivalent.
Public methodStatic memberParse(String, IFormatProvider) Converts the string representation of a number to its System.Half equivalent using the specified culture-specific format information.
Public methodStatic memberParse(String, NumberStyles, IFormatProvider) Converts the string representation of a number to its System.Half equivalent using the specified style and culture-specific format.
Public methodStatic memberSign Returns a value indicating the sign of a half-precision floating-point number.
Public methodStatic memberSubtract Subtracts one specified System.Half value from another.
Public methodStatic memberToHalf(UInt16) Returns a half-precision floating point number converted from its binary representation.
Public methodStatic memberToHalf(Byte, Int32) Returns a half-precision floating point number converted from two bytes at a specified position in a byte array.
Public methodToString Converts the numeric value of this instance to its equivalent string representation.
(Overrides ValueTypeToString)
Public methodToString(IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
Public methodToString(String) Converts the numeric value of this instance to its equivalent string representation, using the specified format.
Public methodToString(String, IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
Public methodStatic memberTryParse(String, HalfType) Converts the string representation of a number to its System.Half equivalent. A return value indicates whether the conversion succeeded or failed.
Public methodStatic memberTryParse(String, NumberStyles, IFormatProvider, HalfType) 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.
Top
Operators
 NameDescription
Public operatorStatic memberAddition(HalfType, HalfType) Adds two specified System.Half values.
Public operatorStatic memberDecrement(HalfType) Decrements the System.Half operand by one.
Public operatorStatic memberDivision(HalfType, HalfType) Divides two specified System.Half values.
Public operatorStatic memberEquality(HalfType, HalfType) Returns a value indicating whether two instances of System.Half are equal.
Public operatorStatic member(Decimal to HalfType) Converts a decimal number to a System.Half.
Public operatorStatic member(Double to HalfType) Converts a double-precision floating-point number to a System.Half.
Public operatorStatic member(HalfType to Byte) Converts a System.Half to an 8-bit unsigned integer.
Public operatorStatic member(HalfType to Char) Converts a System.Half to a Unicode character.
Public operatorStatic member(HalfType to Decimal) Converts a System.Half to a decimal number.
Public operatorStatic member(HalfType to Int16) Converts a System.Half to a 16-bit signed integer.
Public operatorStatic member(HalfType to Int32) Converts a System.Half to a 32-bit signed integer.
Public operatorStatic member(HalfType to Int64) Converts a System.Half to a 64-bit signed integer.
Public operatorStatic member(HalfType to SByte) Converts a System.Half to an 8-bit signed integer.
Public operatorStatic member(HalfType to UInt16) Converts a System.Half to a 16-bit unsigned integer.
Public operatorStatic member(HalfType to UInt32) Converts a System.Half to a 32-bit unsigned integer.
Public operatorStatic member(HalfType to UInt64) Converts a System.Half to a 64-bit unsigned integer.
Public operatorStatic member(Single to HalfType) Converts a single-precision floating-point number to a System.Half.
Public operatorStatic memberGreaterThan(HalfType, HalfType) Returns a value indicating whether a specified System.Half is greater than another specified System.Half.
Public operatorStatic memberGreaterThanOrEqual(HalfType, HalfType) Returns a value indicating whether a specified System.Half is greater than or equal to another specified System.Half.
Public operatorStatic member(Byte to HalfType) Converts an 8-bit unsigned integer to a System.Half.
Public operatorStatic member(Char to HalfType) Converts a Unicode character to a System.Half.
Public operatorStatic member(HalfType to Double) Converts a System.Half to a double-precision floating-point number.
Public operatorStatic member(HalfType to Single) Converts a System.Half to a single-precision floating-point number.
Public operatorStatic member(Int16 to HalfType) Converts a 16-bit signed integer to a System.Half.
Public operatorStatic member(Int32 to HalfType) Converts a 32-bit signed integer to a System.Half.
Public operatorStatic member(Int64 to HalfType) Converts a 64-bit signed integer to a System.Half.
Public operatorStatic member(SByte to HalfType) Converts an 8-bit signed integer to a System.Half.
Public operatorStatic member(UInt16 to HalfType) Converts a 16-bit unsigned integer to a System.Half.
Public operatorStatic member(UInt32 to HalfType) Converts a 32-bit unsigned integer to a System.Half.
Public operatorStatic member(UInt64 to HalfType) Converts a 64-bit unsigned integer to a System.Half.
Public operatorStatic memberIncrement(HalfType) Increments the System.Half operand by 1.
Public operatorStatic memberInequality(HalfType, HalfType) Returns a value indicating whether two instances of System.Half are not equal.
Public operatorStatic memberLessThan(HalfType, HalfType) Returns a value indicating whether a specified System.Half is less than another specified System.Half.
Public operatorStatic memberLessThanOrEqual(HalfType, HalfType) Returns a value indicating whether a specified System.Half is less than or equal to another specified System.Half.
Public operatorStatic memberMultiply(HalfType, HalfType) Multiplies two specified System.Half values.
Public operatorStatic memberSubtraction(HalfType, HalfType) Subtracts two specified System.Half values.
Public operatorStatic memberUnaryNegation(HalfType) Negates the value of the specified System.Half operand.
Public operatorStatic memberUnaryPlus(HalfType) Returns the value of the System.Half operand (the sign of the operand is unchanged).
Top
Fields
 NameDescription
Public fieldStatic memberEpsilon Represents the smallest positive System.Half value greater than zero. This field is constant.
Public fieldStatic memberMaxValue Represents the largest possible value of System.Half. This field is constant.
Public fieldStatic memberMinValue Represents the smallest possible value of System.Half. This field is constant.
Public fieldStatic memberNaN Represents not a number (NaN). This field is constant.
Public fieldStatic memberNegativeInfinity Represents negative infinity. This field is constant.
Public fieldStatic memberOne 
Public fieldStatic memberPositiveInfinity Represents positive infinity. This field is constant.
Public fieldStatic memberZero 
Top
Extension Methods
 NameDescription
Public Extension MethodMethodInvoke Calls the object method by name.
(Defined by ObjectEx)
Public Extension MethodPropertyGet Gets the value of the object property by name.
(Defined by ObjectEx)
Public Extension MethodPropertyGetT Gets the value of the object property by name.
(Defined by ObjectEx)
Public Extension MethodPropertySet Sets the value of the object property by name.
(Defined by ObjectEx)
Top
Remarks
Note: Half is not fast enought and precision is also very bad, so is should not be used for mathematical 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: - Code retrieved from http://sourceforge.net/p/csharp-half/code/HEAD/tree/ on 2015-12-04 - Fast Half Float Conversions, Jeroen van der Zijp, link: http://www.fox-toolkit.org/ftp/fasthalffloatconversion.pdf - IEEE 754 revision, link: http://grouper.ieee.org/groups/754/
See Also