ekmett / bytes

Serialization primitives that work with both cereal and binary.
http://hackage.haskell.org/package/bytes
Other
22 stars 13 forks source link

Use `GHC.Float` functions rather than C code where possible #57

Open RyanGlScott opened 2 years ago

RyanGlScott commented 2 years ago

Currently, bytes defines functions to convert from floating-point values to word values (and vice versa) in i2d.c. However, in base-4.10.0.0 (GHC 8.2) and later, the GHC.Float module offers equivalent functionality in the castDoubleToWord64 function, as well as its cohorts. As far as I can tell, these functions are bit-for-bit compatible, although I'd have to stare at the corresponding Cmm code to know for sure.

If we used the GHC.Float functions instead, we would no longer need to link against C code on recent versions of GHC. This has come up elsewhere in https://github.com/ekmett/bits/pull/7#issuecomment-962594421.