[Haskell-cafe] 16 bit floating point data in Haskell?
lemming at henning-thielemann.de
Mon Sep 28 17:40:59 EDT 2009
On Sun, 27 Sep 2009, Olex P wrote:
> Hi guys,
> Do we have anything like half precision floats in Haskell? Maybe in some non standard
> libraries? Or I have to use FFI + OpenEXR library to achieve this?
If you only want to save storage, you may define
newtype Float16 = Float16 Int16
and write Num, Fractional and Floating instances that convert operands to
Float, perform operations on Float and put the results back to Int16. By
some fusion you may save conversions, but you would also get different
results due to higher precision.
More information about the Haskell-Cafe