BitConverter.ToHalf Method

Definition

Overloads

ToHalf(ReadOnlySpan<Byte>)

Converts a read-only byte span into a half-precision floating-point value.

ToHalf(Byte[], Int32)

Returns a half-precision floating point number converted from two bytes at a specified position in a byte array.

ToHalf(ReadOnlySpan<Byte>)

Source:
BitConverter.cs
Source:
BitConverter.cs
Source:
BitConverter.cs

Converts a read-only byte span into a half-precision floating-point value.

C#
public static Half ToHalf(ReadOnlySpan<byte> value);

Parameters

value
ReadOnlySpan<Byte>

A read-only span containing the bytes to convert.

Returns

A half-precision floating-point value that represents the converted bytes.

Exceptions

The length of value is less than 2.

Applies to

.NET 10 ja muud versioonid
Toode Versioonid
.NET 6, 7, 8, 9, 10

ToHalf(Byte[], Int32)

Source:
BitConverter.cs
Source:
BitConverter.cs
Source:
BitConverter.cs

Returns a half-precision floating point number converted from two bytes at a specified position in a byte array.

C#
public static Half ToHalf(byte[] value, int startIndex);

Parameters

value
Byte[]

An array of bytes that includes the two bytes to convert.

startIndex
Int32

The starting position within value.

Returns

A half-precision floating point number formed by two bytes beginning at startIndex.

Exceptions

startIndex equals the length of value minus 1.

value is null.

startIndex is less than zero or greater than the length of value minus 1.

Applies to

.NET 10 ja muud versioonid
Toode Versioonid
.NET 6, 7, 8, 9, 10