Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

Neslib.Half

Half-Precision Floating-Point for Delphi

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

Neslib.Half - Half-Precision Floating-Point for Delphi

This small library defines the Half type, which is a 16-bit half-precision floating-point value.

The Half type uses overloaded operators so you can use it just like a Single or Double type (albeit with lower precision).

The Neslib.Half unit also defines a record helper for the Half type to provide access to the internals of the Half type (in a similar way that there are record helpers for the Single and Double types).

The Half type is used by some image formats to provide a higher dynamic range than 8 bits per channel, without resorting to the overhead of using 32 bits per channel. You can also use it for more efficient storage of floating-point values in case the value can be fit into a Half without loss of precision. You can use GetSmallestFloatType to determine if a Double value fits into a Single or Half without loss of precision.

This library uses fast conversion algorithms developed by Jeroen van der Zijp to convert from Half to Single and vice versa in a fast but accurate way (see his paper "Fast Half Float Conversions").

License

Neslib.Half is licensed under the Simplified BSD License.

See License.txt for details.