Table of Contents

Struct Half

Namespace
Stride.Core.Mathematics
Assembly
Stride.Core.Mathematics.dll

A half precision (16 bit) floating point value.

[DataContract]
public struct Half

Constructors

Half(float)

Initializes a new instance of the Half structure.

public Half(float value)

Parameters

value float

The floating point value that should be stored in 16 bit format.

Fields

AdditionRounding

Additional rounding.

public const int AdditionRounding = 1

Field Value

int

Epsilon

Smallest such that 1.0 + epsilon != 1.0

public static readonly float Epsilon

Field Value

float

ExponentRadix

Exponent radix.

public const int ExponentRadix = 2

Field Value

int

MantissaBits

Number of bits in the mantissa.

public const int MantissaBits = 11

Field Value

int

MaxValue

Maximum value of the number.

public static readonly float MaxValue

Field Value

float

MaximumBinaryExponent

Maximum binary exponent.

public const int MaximumBinaryExponent = 15

Field Value

int

MaximumDecimalExponent

Maximum decimal exponent.

public const int MaximumDecimalExponent = 4

Field Value

int

MinValue

Minimum value of the number.

public static readonly float MinValue

Field Value

float

MinimumBinaryExponent

Minimum binary exponent.

public const int MinimumBinaryExponent = -14

Field Value

int

MinimumDecimalExponent

Minimum decimal exponent.

public const int MinimumDecimalExponent = -4

Field Value

int

One

A Half whose value is 1.0f.

public static readonly Half One

Field Value

Half

PrecisionDigits

Number of decimal digits of precision.

public const int PrecisionDigits = 3

Field Value

int

Zero

A Half whose value is 0.0f.

public static readonly Half Zero

Field Value

Half

Properties

RawValue

Gets or sets the raw 16 bit value used to back this half-float.

public ushort RawValue { get; set; }

Property Value

ushort

Methods

ConvertToFloat(Half[])

Converts an array of half precision values into full precision values.

public static float[] ConvertToFloat(Half[] values)

Parameters

values Half[]

The values to be converted.

Returns

float[]

An array of converted values.

ConvertToHalf(float[])

Converts an array of full precision values into half precision values.

public static Half[] ConvertToHalf(float[] values)

Parameters

values float[]

The values to be converted.

Returns

Half[]

An array of converted values.

Equals(Half)

Returns a value that indicates whether the current instance is equal to the specified object.

public bool Equals(Half other)

Parameters

other Half

Object to make the comparison with.

Returns

bool

true if the current instance is equal to the specified object; false otherwise.

Equals(ref readonly Half, ref readonly Half)

Determines whether the specified object instances are considered equal.

public static bool Equals(ref readonly Half value1, ref readonly Half value2)

Parameters

value1 Half

The first value.

value2 Half

The second value.

Returns

bool

true if value1 is the same instance as value2 or if both are null references or if value1.Equals(value2) returns true; otherwise, false.

Equals(object)

Returns a value that indicates whether the current instance is equal to a specified object.

public override bool Equals(object obj)

Parameters

obj object

Object to make the comparison with.

Returns

bool

true if the current instance is equal to the specified object; false otherwise.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.

ToString()

Converts the value of the object to its equivalent string representation.

public override string ToString()

Returns

string

The string representation of the value of this instance.

Operators

operator ==(Half, Half)

Tests for equality between two objects.

public static bool operator ==(Half left, Half right)

Parameters

left Half

The first value to compare.

right Half

The second value to compare.

Returns

bool

true if left has the same value as right; otherwise, false.

explicit operator Half(float)

Performs an explicit conversion from float to Half.

public static explicit operator Half(float value)

Parameters

value float

The value to be converted.

Returns

Half

The converted value.

implicit operator float(Half)

Performs an implicit conversion from Half to float.

public static implicit operator float(Half value)

Parameters

value Half

The value to be converted.

Returns

float

The converted value.

operator !=(Half, Half)

Tests for inequality between two objects.

public static bool operator !=(Half left, Half right)

Parameters

left Half

The first value to compare.

right Half

The second value to compare.

Returns

bool

true if left has a different value than right; otherwise, false.