Half is a new binary floating-point type in .NET 5 Preview 7 to speed up ML workflows
By Ather Fawaz · Sep 1, 2020
By Ather Fawaz · Sep 1, 2020
[SHOWTOGROUPS=4,20,22]
Для просмотра ссылки Войдиили Зарегистрируйся
In .NET 5 Preview 7, Microsoft has now introduced another floating-point datatype alongside the standard Float and Double.
Dubbed Half, the Для просмотра ссылки Войдиили Зарегистрируйся is equivalent to binary16, which is specified in the Для просмотра ссылки Войди или Зарегистрируйся standard for floating-point arithmetic.
Unlike Float and Double in C#, which occupy 32 bits and 64 bits respectively, Half will be based on 16 bits. These bits will be split as follows: one sign bit, five exponent bits, and 10 mantissa bits. Taken together, Half can represent and store values in the range ±65504.
This decrease in precision is where the datatype gets its name from in the first place. One rather strange implication of this format is that a Half can store both positive zero and negative zero:
Further details can be Для просмотра ссылки Войдиили Зарегистрируйся
[/SHOWTOGROUPS]
Для просмотра ссылки Войди
In .NET 5 Preview 7, Microsoft has now introduced another floating-point datatype alongside the standard Float and Double.
Dubbed Half, the Для просмотра ссылки Войди
Unlike Float and Double in C#, which occupy 32 bits and 64 bits respectively, Half will be based on 16 bits. These bits will be split as follows: one sign bit, five exponent bits, and 10 mantissa bits. Taken together, Half can represent and store values in the range ±65504.
This decrease in precision is where the datatype gets its name from in the first place. One rather strange implication of this format is that a Half can store both positive zero and negative zero:
- 1 00000 0000000000 = -0
- 0 00000 0000000000 = +0
It is expected that the Half will find its way into many codebases and will soon be supported in C# as a half datatype as it promises faster computation and efficiency in ML workflows.In .NET 5.0, the Half type is primarily an interchange type with no arithmetic operators defined on it. It only supports parsing, formatting and comparison operators. All arithmetic operations will need an explicit conversion to a float/double. Future versions will consider adding arithmetic operators directly on Half.
Further details can be Для просмотра ссылки Войди
[/SHOWTOGROUPS]