[Haskell-cafe] ANN: reinterpret-cast - byte-casting word-size numbers

Niklas Hambüchen mail at nh2.me
Wed Apr 30 15:28:04 UTC 2014


Announcing the first version of the reinterpret-cast package:

Hackage: http://hackage.haskell.org/package/reinterpret-cast
Github: https://github.com/nh2/reinterpret-cast

Takes the bit representation of a number and uses it for a different
numeric type. This is reinterpret_cast from C++ and float f = 1.23; int
i = * (int *) &f; from C.

I started writing this because the PointCloudLibrary project (PCL) makes
RGB colours available as an int-packed format cast to a float value -
that's silly but oh the legacy. I was surprised that fast reinterpret
casts are not readily available in base or at least GHC, but there are
improvements going on (see links in the README). Meanwhile this package
is for dealing with it.

The way implemented here is the fastest possible way known to me as of
now. In particular, it is faster than what data-binary-ieee754 does at
the moment.

Contributions are very welcome.


More information about the Haskell-Cafe mailing list