This article is more than 1 year old

Not Half bad: Microsoft back to 16 bits with new storage-saving type in .NET 5

For when precision isn't so important

Microsoft shone light today on a new type, Half, lurking within the depths of .NET 5 Preview 7, aimed at adding another IEEE 754 format as well as saving a bit of storage space.

While float (equivalent to binary32) and double (equivalent to binary64) have long been familiar to users of the framework, binary16 has been missing in action (along with others, such as binary128).

Those battling with floating point numbers and happy to swap precision for storage need fret no longer as Half has taken a bow in the preview framework.

An unusual move for a company more normally associated with ballooning storage requirements, Half requires a mere 16 bits to store a binary floating-point number. "With half the number of bits as float, a Half number can represent values in the range ±65504," explained the post.

The 16 bits are split into a sign bit, five exponent bits and 10 significand bits (although the team said that the total precision was actually 11 bits). "The format," the team added, "is assumed to have an implicit leading bit of value 1." The smallest positive non-zero Half number is therefore 0.000000059604645 and the largest 65504.

Half values can be represented as float or double numbers without losing precision. Obviously, going to the 16 bits of Half from something with more precision could well see some losses. Being intended for interchange purposes, Half also lacks the arithmetic operators of float and double. Only parsing, formatting and comparison are in .NET 5.0 at present, although "future versions will consider adding arithmetic operators directly on Half."

Nvidia: Eight bits ought to be enough for anybody ... doing AI


The gang reckons that the new type will save on storage space where greater precision is not required and will see use in the machine learning sphere, among others. It also enjoys hardware support in both GPU and CPU worlds.

Sadly, there is no love for other floating point types, such as binary128. The author of the post, Prashanth Govindarajan, noted that Half was all the team could squeeze in this time around (and it could prove handy for the ML.NET project). Govindarajan also speculated that x86 and ARM processors would experience "accelerated... computation performance" once more intrinsics are supported in .NET.

Microsoft engineer Tanner Gooding added that unlike Half, binary128 did not enjoy so much hardware support and was "almost entirely software driven".

Gooding went on to suggest that binary128 was also a little more niche, adding: "I would speculate those that want a Binary128 would also want a BigFloat type, so they can also have Binary256 or Binary512."

Those pesky, demanding users that want such things can pop over to the GitHub repo for the project and make their feelings known. Gooding himself opened an issue along those lines in 2018. ®

More about


Send us news

Other stories you might like